From ed85b269d8f5ed6822ef0d3274b3ec104f637456 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 11 Oct 2024 11:14:14 -0400 Subject: [PATCH] Support finding the reference GTF properly even for spaceranger versions > 3.0.0 Co-authored-by: Manisha Barse --- R/read10xVisiumWrapper.R | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/R/read10xVisiumWrapper.R b/R/read10xVisiumWrapper.R index d9f31fc2..430943e9 100644 --- a/R/read10xVisiumWrapper.R +++ b/R/read10xVisiumWrapper.R @@ -60,7 +60,18 @@ read10xVisiumWrapper <- function( if (missing(reference_gtf)) { summary_file <- file.path(samples[1], "web_summary.html") web <- readLines(summary_file) + + # For spaceranger versions before 3.0 reference_path <- gsub('.*"', "", regmatches(web, regexpr('\\["Reference Path", *"[/|A-z|0-9|-]+', web))) + + # For recent spaceranger versions (3.0.0+?) + if (length(reference_path) == 0) { + reference_path = sub( + '.*--transcriptome=(\\S*).*', + '\\1', + web[grep('--transcriptome=', web)] + ) + } reference_gtf <- file.path(reference_path, "genes", "genes.gtf") } reference_gtf <- reference_gtf[file.exists(reference_gtf)]