前面我们也遇到过10x的数据读取不进去,如果大家遇到下面的报错,可以通过修改10x的原始重新读取,详细可以见链接https://blog.csdn.net/weixin_43949246/article/details/121225791
当然,这次跟大家说的是另一种10x的数据,同样的,我们先说报错,如果出现dgTMatrix的报错,我们该怎么办呢?
这里给大家推荐一种解决方法,首先先定义个函数,修改读取的方式
read10x_ymc <- function(
data.dir = NULL,
gene.column = 2,
unique.features = TRUE,
strip.suffix = FALSE,
prefix='',
suffix="tsv"
) {
full.data <- list()
for (i in seq_along(along.with = data.dir)) {
run <- data.dir[i]
if (!dir.exists(paths = run)) {
stop("Directory provided does not exist")
}
barcode.loc <- file.path(run, paste(prefix,'barcodes.',suffix,sep=''))
gene.loc <- file.path(run, paste(prefix,'genes.',suffix,sep=''))
features.loc <- file.path(run, paste(prefix,'features.',suffix,'.gz',sep=''))
matrix.loc=file.path(run,paste(prefix,'matrix.mtx',sep=''))
# Flag to indicate if this data is from CellRanger >= 3.0
pre_ver_3 <- file.exists(gene.loc)
if (!pre_ver_3) {
addgz <- function(s) {
return(paste0(s, ".gz"))
}
barcode