我正在使用以下代码。
1.clones.tsv
的文件有 22204
行。
read_mixcr_n_trans<- function(file,...){
df <- read.delim(file)
# transform the cell id {be consist with RNA data}
{
well<- gsub(df$cellId,pattern = "[AGCT]*-",replacement = "")
hp<- gsub(df$cellId,pattern = "-[AGCT]*-.*",replacement = "")
rt<- str_extract(df$cellId,pattern = "-[AGCT]{10}")%>%
str_sub(.,start = 2,end = nchar(.))
}
# add a column named "tagValueCELL" {as normal mixcr output}
df$tagValueCELL<- paste(well,hp,rt,sep ="_" )
return(df)
}
fn1 <- "1.clones.tsv"
filelist <- c(fn1)
samples <- c("A")
contig_list<- lapply(filelist, function(x) read_mixcr_n_trans(x))
Error in `$<-.data.frame`(`*tmp*`, tagValueCELL, value = character(0)) :
replacement has 0 rows, data has 22204
回溯
7.
stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
"replacement has %d rows, data has %d"), N, nrows), domain = NA)
6.
`$<-.data.frame`(`*tmp*`, tagValueCELL, value = character(0))
5.
`$<-`(`*tmp*`, tagValueCELL, value = character(0))
4.
read_mixcr_n_trans(x)
3.
FUN(X[[i]], ...)
2.
lapply(filelist, function(x) read_mixcr_n_trans(x))
1.
lapply(filelist, function(x) read_mixcr_n_trans(x))
调试
function (x, name, value)
{
cl <- oldClass(x)
class(x) <- NULL
nrows <- .row_names_info(x, 2L)
if (!is.null(value)) {
N <- NROW(value)
if (N > nrows)
stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
"replacement has %d rows, data has %d"), N,
nrows), domain = NA)
if (N < nrows)
if (N > 0L && (nrows%%N == 0L) && length(dim(value)) <=
1L)
value <- rep(value, length.out = nrows)
else stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
"replacement has %d rows, data has %d"), N,
nrows), domain = NA)
if (is.atomic(value) && !is.null(names(value)))
names(value) <- NULL
}```
`Debug location is approximate because the source is not available`
well<- gsub(df$cellId,pattern = "[AGCT]*-",replacement = "")
hp<- gsub(df$cellId,pattern = "-[AGCT]*-.*",replacement = "")
rt<- str_extract(df$cellId,pattern = "-[AGCT]{10}")%>%
将“cellID”更改为“tagValueCELL”
read_mixcr_n_trans<- function(file,...){
df <- read.delim(file)
# transform the cell id {be consist with RNA data}
{
well<- gsub(df$tagValueCELL,pattern = "[AGCT]*-",replacement = "")
hp<- gsub(df$tagValueCELL,pattern = "-[AGCT]*-.*",replacement = "")
rt<- str_extract(df$tagValueCELL,pattern = "-[AGCT]{10}")%>%
str_sub(.,start = 2,end = nchar(.))
}
# add a column named "tagValueCELL" {as normal mixcr output}
df$tagValueCELL<- paste(well,hp,rt,sep ="_" )
return(df)
}
fn1 <- "36.clones.tsv"
filelist <- c(fn1)
samples <- c("A")
contig_list<- lapply(filelist, function(x) read_mixcr_n_trans(x))