r - Error in UseMethod("select_") : no applicable method for 'select_' applied to an object of class "NULL" -
i strange error when knitting
r markdown html file. think has sort of incompatibility in dplyr
package knitr
.
update: replaced cbind
chunk dplyr::bind_cols
command, suggested below not use cbind
dplyr
. however, different, equally incomprehensible error:
library(dplyr) counts.all <- bind_cols(count.tables[["sf10281"]], count.tables[["sf10282"]])
the error change (again, when knitting):
error in eval(expr, envir, enclos) : not compatible strsxp calls: <anonymous> ... withvisible -> eval -> eval -> bind_cols -> cbind_all -> .call
previous error cbind
instead of dplyr::bind_cols
:
running chunks separately works fine, , able knit
fine until added last chunk (using select
dplyr
).
this error get:
quitting lines 75-77 (analysis_sf10281_sf10282_sep29_2015.rmd) error in usemethod("select_") : no applicable method 'select_' applied object of class "null" calls: <anonymous> ... withvisible -> eval -> eval -> <anonymous> -> select_
this entire rmd file:
read-in gene count tables single list of data frames (one data frame per sample):
```{r} count.files <- list.files(pattern = "^sf[0-9]+_counts.txt$") count.tables <- lapply(count.files, read.table, header=t, row.names=1) names(count.tables) <- gsub("\\_counts.txt", "", count.files) ```
remove gene metadata columns:
```{r} count.tables <- lapply(count.tables, `[`, -(1:5)) ```
rename cells (columns) short version:
```{r} count.tables <- lapply(count.tables, function(x) {names(x) <- gsub("x.diazlab.aaron.tophat_out.sf[0-9]+.sample_(sf[0-9]+).[0-9]+.([a-z][0-9]+).accepted_hits.bam", "\\1-\\2", names(x)); x}) ```
save object file later: {r} saverds(count.tables, file="gliomarawcounts_10281_10282_10345_10360.rds")
make single data frame 4 samples (384 cells), , write text file:
```{r} counts.all <- cbind(count.tables[["sf10281"]], count.tables[["sf10282"]], count.tables[["sf10345"]], count.tables[["sf10360"]]) write.table(counts.all, file="gliomarawcounts_10281_10282_10345_10360.txt", sep="\t", quote=f, col.names=na) ```
read metadata. not assign cell id column row.names, compatibility dplyr.
```{r} meta <- read.delim("qc_metrics_scell_sf10281_sf10282_sf10345_sf10360.txt", check.names = f, stringsasfactors = f) ```
filter cells based on live/dead/multi calls. exclude empty, red-only, , multi-cell wells:
```{r, results='hide', message=false, warning=false} library(dplyr) meta.select <- filter(meta, grepl("^1g", `live-dead_call`)) ```
filter cells based on 1,000 gene threshold:
(includes 12 'fail' cells) ```{r} meta.select <- filter(meta.select, genes_tagged > 1000) ```
subset counts table include cells passed qc.
```{r} counts.select <- dplyr::select(counts.all, one_of(meta.select$id)) head(counts.select[,1:10]) ```
Comments
Post a Comment