You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stop("More than one 'reference_gtf' was provided or detected. Manually specify the path to just one 'reference_gtf'. If different GTF files were used, then different genes will have been quantified and thus cannot be merged naively into a single SpatialExperiment object. If that's the case, we recommend you build separate SPE objects based on the different 'reference_gtf' files used.", call.=FALSE)
82
-
} elseif (length(reference_gtf) ==0) {
83
-
stop("No 'reference_gtf' files were detected. Please check that the files are available.", call.=FALSE)
58
+
verbose=TRUE,
59
+
add_analysis=TRUE
60
+
) {
61
+
if (!all(c("gene_name", "gene_id") %in%gtf_cols)) {
62
+
stop("'gtf_cols' must include 'gene_name' and 'gene_id'", call.=FALSE)
84
63
}
85
64
86
65
if (verbose) message(Sys.time(), " SpatialExperiment::read10xVisium: reading basic data from SpaceRanger")
if (verbose) message(Sys.time(), " read10xVisiumAnalysis: reading analysis output from SpaceRanger")
97
-
visium_analysis<- read10xVisiumAnalysis(
75
+
spe<- spe_add_info(
76
+
spe=spe,
98
77
samples=samples,
99
-
sample_id=sample_id
78
+
sample_id=sample_id,
79
+
reference_gtf=reference_gtf,
80
+
chrM=chrM,
81
+
gtf_cols=gtf_cols,
82
+
add_analysis=add_analysis,
83
+
verbose=verbose
100
84
)
101
85
102
-
if (verbose) message(Sys.time(), " add10xVisiumAnalysis: adding analysis output from SpaceRanger")
103
-
spe<- add10xVisiumAnalysis(spe, visium_analysis)
104
-
105
-
## Read in the gene information from the annotation GTF file
106
-
if (verbose) message(Sys.time(), " rtracklayer::import: reading the reference GTF file")
107
-
gtf<-rtracklayer::import(reference_gtf)
108
-
gtf<-gtf[gtf$type=="gene"]
109
-
names(gtf) <-gtf$gene_id
110
-
111
-
## Match the genes
112
-
if (verbose) message(Sys.time(), " adding gene information to the SPE object")
113
-
match_genes<- match(rownames(spe), gtf$gene_id)
114
-
115
-
if (all(is.na(match_genes))) {
116
-
## Protect against scenario where one set has GENCODE IDs and the other one has ENSEMBL IDs.
117
-
warning("Gene IDs did not match. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger. For example, one file uses GENCODE IDs and the other one ENSEMBL IDs. read10xVisiumWrapper() will try to convert them to ENSEMBL IDs.", call.=FALSE)
warning("Dropping ", sum(is.na(match_genes)), " out of ", length(match_genes), " genes for which we don't have information on the reference GTF file. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger.", call.=FALSE)
123
-
## Drop the few genes for which we don't have information
0 commit comments