knitting 这个R Markdown进入HTML文件时,我收到一个奇怪的错误 . 我认为它与 dplyr 包中的某种不兼容性有关 knitr .

UPDATE: I replaced the cbind chunk with the dplyr::bind_cols command, as someone suggested below not to use cbind with dplyr. However, I now get a different, equally incomprehensible error:

library(dplyr) counts.all <- bind_cols(count.tables[["SF10281"]], count.tables[["SF10282"]])

我得到这个改变的错误(再次,只有在编织时):

Error in eval(expr, envir, enclos) : not compatible with STRSXP Calls: <Anonymous> ... withVisible -> eval -> eval -> bind_cols -> cbind_all -> .Call


Previous error with cbind instead of dplyr::bind_cols:

单独运行块工作正常,我能够 knit 罚款,直到我添加最后一个块(使用 select 中的 select ) .

This is the error I get:

Quitting from lines 75-77 (Analysis_SF10281_SF10282_Sep29_2015.Rmd) 
Error in UseMethod("select_") : 
  no applicable method for 'select_' applied to an object of class "NULL"
Calls: <Anonymous> ... withVisible -> eval -> eval -> <Anonymous> -> select_

This is the entire Rmd file:

将基因计数表读入单个数据帧列表(每个样本一个数据帧):

```{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)

删除基因元数据列:

```java
```{r}
count.tables <- lapply(count.tables, `[`, -(1:5))

将单元格(列)重命名为短版本:

```java
```{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})

将对象保存到文件以供日后使用: `{r} saveRDS(count.tables, file="gliomaRawCounts_10281_10282_10345_10360.rds")` 

使用所有4个样本(384个单元格)创建单个数据框,并写入文本文件:

```java
```{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)

读取元数据 . 不要将cell ID列指定为row.names,以便与dplyr兼容 . 

```java
```{r}
meta <- read.delim("QC_metrics_SCell_SF10281_SF10282_SF10345_SF10360.txt", check.names = F, stringsAsFactors = F)

根据实时/死/多呼叫过滤单元格 . 排除空的,仅红色的和多细胞的孔:

```java
```{r, results='hide', message=FALSE, warning=FALSE}
library(dplyr)
meta.select <- filter(meta, grepl("^1g", `Live-dead_call`))

根据1,000个基因阈值过滤细胞:

```java
(Includes 12 'FAIL' cells)
```{r}
meta.select <- filter(meta.select, Genes_tagged > 1000)

子集计数表仅包括通过QC的单元格 . 

```java
```{r}
counts.select <- dplyr::select(counts.all, one_of(meta.select$ID))
head(counts.select[,1:10])