改写后读⼊数据
stop("Directory provided does not exist")豌豆苗需要焯水吗
}
barcode.loc <- file.path(run, paste(prefix,'barcodes.',suffix,p=''))
gene.loc <- file.path(run, paste(prefix,'genes.',suffix,p=''))
features.loc <- file.path(run, paste(prefix,'features.',suffix,'.gz',p=''))
if( ists(file.path(run,paste(prefix,'',p='')))){matrix.loc <- file.path(run,prefix,paste(prefix,'',p=''))}el{matrix.loc <- file.path(run,paste(prefix,'mtx',s # Flag to indicate if this data is from CellRanger >= 3.0
pre_ver_3 <- ists(gene.loc)
if (!pre_ver_3) {
addgz <- function(s) {
return(paste0(s, ".gz"))
}
barcode.loc <- addgz(s = barcode.loc)
matrix.loc <- addgz(s = matrix.loc)
}
if (!ists(barcode.loc)) {
stop("Barcode file missing. Expecting ", baname(path = barcode.loc))
山川之美}
if (!pre_ver_3 && !ists(features.loc) ) {
stop("Gene name or features file missing. Expecting ", baname(path = features.loc))
}
if (!ists(matrix.loc)) {
print(matrix.loc)
stop("Expression matrix file missing. Expecting ", baname(path = matrix.loc))
}
data <- readMM(file = matrix.loc)
cell.names <- readLines(barcode.loc)
if(!dim(data)[2]==length(cell.names)){data <- t(readMM(file = matrix.loc))}###这是与cellranger输出结果最⼤的不同
if (all(grepl(pattern = "\\-1$", x = cell.names)) & strip.suffix) {
cell.names <- as.vector(x = as.character(x = sapply(
X = cell.names,
FUN = ExtractField,
field = 1,
delim = "-"
)))
}
if (is.null(x = names(x = data.dir))) {
if (i < 2) {
colnames(x = data) <- cell.names
急救用品} el {
colnames(x = data) <- paste0(i, "_", cell.names)
}
} el {
colnames(x = data) <- paste0(names(x = data.dir)[i], "_", cell.names)
}作风整顿心得体会
feature.names <- read.delim(
file = ifel(test = pre_ver_3, yes = gene.loc, no = features.loc),
header = FALSE,
stringsAsFactors = FALSE
)
if (any(is.na(x = feature.names[, lumn]))) {
整人
warning(
'Some features names are NA. Replacing NA names with ID from the opposite column requested',
理念说
call. = FALSE,
immediate. = TRUE
)
na.features <- which(x = is.na(x = feature.names[, lumn]))
feature.names[na.features, lumn] <- feature.names[na.features, lumn]
}
if (unique.features) {
白老鼠fcols = ncol(x = feature.names)
if (fcols < lumn) {
stop(paste0("lumn was t to ", lumn,
" but (or genes.tsv) only has ", fcols, " columns.",
" Try tting lumn argument to a value <= to ", fcols, "."))
}
rownames(x = data) <- make.unique(names = feature.names[, lumn])
}
罗托鲁阿
# In cell ranger 3.0, a third column specifying the type of data was added
# and we will return each type of data as a parate matrix
if (ncol(x = feature.names) > 2) {
data_types <- factor(x = feature.names$V3)
lvls <- levels(x = data_types)