thelovelab/tximport

Idea: Supporting alevin output

PeteHaitch opened this issue · 10 comments

(Unsure if this idea belongs here, in the tximeta repo, or in the salmon repo. Apologies if I guessed wrong. Tagging @rob-p and @k3yavi for their thoughts).

I'm looking into using the alevin tool from salmon for processing 3'-tag scRNA-seq data (currently just in the planning stage for such a workflow).
In such a workflow I'll ultimately be wanting to get the gene-sample count matrix created by alevin into a SingleCellExperiment (ideally with all the metadata via the very awesome tximeta).

Looking at the alevin docs (https://salmon.readthedocs.io/en/latest/alevin.html#output):

by default alevin dumps a per-cell level gene-count matrix in a binary-compressed format with the row and column indexes in a separate file.
A typical run of alevin will generate 3 files:
quants_mat.gz – Compressed count matrix.
quants_mat_cols.txt – Column Header (Gene-ids) of the matrix.
quants_mat_rows.txt – Row Index (CB-ids) of the matrix.
Alevin can also dump the count-matrix in a human readable – comma-separated-value (CSV) format

It's probably worth noting that the CSV version has cells along the rows and genes along the columns (i.e. opposite of SingleCellExperiment).

So a few questions:

@mikelove

  • Have you explored importing alevin output into R/Bioconductor?
  • Would you be interested in having this functionality in tximport?

@rob-p and @k3yavi

  • You note that the output format for scRNA-seq is itself an area of open research. Do you think the current formats are stable enough for me (and others?) to invest time in writing importers for R/Bioconductor?
  • Is there a more detailed description of the 'compressed count matrix' format (I'd like to see whether it maps to one of the sparse matrix formats in the R Matrix package).
  • Somewhat tangentially, have you considered HDF5 support (recognising that this I think this is quite a heavy thing to incorporate with and probably overkill for experiments with a few thousand cells)?

Thanks, I'm eager to hear your thoughts
Pete

Thanks Pete,

This looks a good suggestion (haven't tried importing yet), and tximport probably makes sense as the place where it should live.

First thing I need to start working on it is some minimal example data that I can put into tximportData so we can have proper testing and vignette code. I'll coordinate with @rob-p and @k3yavi on it.

For timeline, I'm pretty busy the next few weeks with revisions and school starting, but we'll make it happen. Cool if we could do it before release in Oct.

I should have an alevin-processed dataset this week, but I don't think it'll be shareable. If @rob-p or @k3yavi already have one, that'd be ideal for inclusions in tximportData.

If you're interested in working together, I may have some time over the next few weeks to begin on this.

Hi guys,
Thanks for considering Alevin to be included in tximport, I think it would open up the gateway for Alevin to the awesome R world.
I have tried a stupid connection of Alevin -> R (Seurat) here although it starts from a csv file.
Not to bug @mikelove since I totally understand how busy it would be with the school opening up soon but when you guys have time the binary version of the matrix can be found here (inside folder alevin). Do let me know if you guys need any other help.

@k3yavi what set of files should i put in tximportData to use for testing?

6.3K MappedUmi.txt
2.5K alevin.log
133K barcodeSoftMaps.txt
9.6M cell_eq_info.txt
2.4M cell_eq_mat.gz
5.0K cell_eq_order.txt
15K featureDump.txt
1.7K predictions.txt
1.6M quants_mat.gz
2.0M quants_mat_cols.txt
5.0K quants_mat_rows.txt
6.4K raw_cb_frequency.txt
5.9M transcripts.txt
1.6K whitelist.txt

Hi @mikelove ,

The relevant files would quants_mat* i.e.

  • quants_mat.gz: the compressed matrix of double
  • quants_mat_cols.txt: the name of the columns (gene names) in the above matrix.
  • quants_mat_rows.txt: the name of the rows (CB) in the above matrix.

Sorry this didn’t happen by release, got sidetracked by some revisions and other stuff. I’ll be working on this in the new development branch

Totally understandable, I've also not spent time on it either due to other commitments

No worries @mikelove .
Just let me know once you have a stable version, I'll just copy paste the R code to parse the quants here 😜 .

Hi @mikelove ,
There has been a couple of users asking for reading the gzip output format of Alevin in R, I am attaching a snippet of code which I wrote for parsing the output, hope it might help in tximport too. Please let me know if you see something that can be made more efficient in the attached R code.
readAlevin.R.txt

In devel branch