Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue due to missing spot barcodes in raw matrix #15

Closed
mattcai10x opened this issue Mar 29, 2023 · 10 comments
Closed

Issue due to missing spot barcodes in raw matrix #15

mattcai10x opened this issue Mar 29, 2023 · 10 comments

Comments

@mattcai10x
Copy link

Hi @zijianni ,

It was brought to my attention that running spotclean can have issues when the set of barcodes in the raw matrix does not match the set of barcodes in the tissue positions csv. This occurs when one or more spots has 0 reads, since the raw matrix only contains spot barcodes with > 0 reads and the tissue positions csv contains all barcodes. While this isn't very common in Visium data, it is the intended behavior of Space Ranger.

Thanks for developing and maintaining this package for Visium users,
Matt

@zijianni
Copy link
Owner

Hi @mattcai10x ,

Thanks for sharing your findings! Unfortunately I won't be able to investigate the issue until the week of 04/08. Are you saying that, forget about SpotClean, the raw barcode matrix from SpaceRanger output would be pre-filtered to remove empty barcodes? This seems inconsistent with CellRanger where I remembered the raw barcode matrix usually has a fixed dimension (~737,280 barcodes?) Or are there recent updates in CellRanger and SpaceRanger where the empty barcodes are now filtered out?

@mattcai10x
Copy link
Author

I actually did not know this but it looks like the change happened in CellRanger 6.0 and SpaceRanger 1.3.

@Streisenberg
Copy link

Hey!

I am facing the same issue. Upon reviewing my slide_info file, I noticed a discrepancy of 120 barcodes, which are different from the 14216 barcodes in my raw data. Is there an existing solution to address this problem, or is it sufficient to simply eliminate those inconsistent barcodes and proceed with the analysis?

Thank you!

@zijianni
Copy link
Owner

Hi @Streisenberg , thanks for reporting your issue. Are you seeing 120 barcodes in slide_info but not in the raw matrix? And is your data coming from Visium platform? Not aware they are extending the number of spots to >14000.

@Streisenberg
Copy link

Hi @zijianni , thank you for your prompt attention to this matter. Yes, that is correct, I have 120 more barcodes in my slide_info object.

And yes the data comes from the Visium CytAssist platform. I attached their 11x11mm slides here which contain >14000 barcodes within the capture area.

Screen Shot 2023-10-13 at 8 48 40 PM

Thank you!

@zijianni
Copy link
Owner

Thanks for sharing! Yes, you are good to drop the 120 missing barcodes from slide_info.

Note that the bigger Visium slide (~ 14000 spots) was not available at the time our paper was published, so you might want to validate the generated results before downstream analysis. Another note that the computation time and memory usage will increase with more spots in your data. The optimization process cannot easily be parallelized due to the iterative nature of EM algorithm.

@Streisenberg
Copy link

Thanks a lot (:

@yeswzc
Copy link

yeswzc commented Oct 20, 2023

I have the same issue in one of my data. Discard those not in the raw matrix can solve this.

m.raw <- read10xRaw(file.path(data.home, sample.name,"outs/raw_feature_bc_matrix"))
DEPRECATED.idx <- grep("DEPRECATED", rownames(m.raw))
m.raw <- m.raw[-DEPRECATED.idx,]
 
m.slideInfo <- read10xSlide(file.path(data.home, sample.name,"outs/spatial/tissue_positions.csv"),
                                file.path(data.home, sample.name,"outs/spatial/tissue_lowres_image.png"),
                                file.path(data.home, sample.name,"outs/spatial/scalefactors_json.json"))

if(sum(!m.slideInfo$slide$barcode %in% colnames(m.raw)) > 0){m.slideInfo$slide = m.slideInfo$slide[m.slideInfo$slide$barcode %in% colnames(m.raw),]  }
m.obj <- createSlide(count_mat = m.raw, slide_info = m.slideInfo)


@zijianni
Copy link
Owner

zijianni commented Nov 2, 2023

Given that more people are facing the same issue, I will implement a fix in createSlide() to remove spots in slide metadata but not in raw expression matrix.

@zijianni
Copy link
Owner

zijianni commented Nov 4, 2023

Addressed in #24 . After the PR merge, this feature is available in the dev package. The Bioconductor version needs to wait for the next release.

@zijianni zijianni closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants