Entering edit mode
Good afternoon,
Can anyone advice me on how to perform a conversion from a Seurat Object to a Summarised Experiment or ExpressionSet. I need this format unfortunately for a specific software.
Thank you very much!
Also, you almost surely don't want a
SummarizedExperiment
and for sure you don't want anExpressionSet
. You want aSingleCellExperiment
object.No, I want a SummarisedExperiment or ExpressionSet. I need it in this format.
A
SingleCellExperiment
IS aSummarizedExperiment
, with added features required for scRNA-Seq analyses. The basicSummarizedExperiment
object is meant for bulk RNA-Seq or microarray data, and doesn't have things like areducedDims
slot. I suppose you could just pull out things that map from aSingleCellExperiment
to aSummarizedExperiment
, but I am 99% sure there isn't a coercion method, so you are likely on your own if you really have to use aSummarizedExperiment
.Its because I want to run the GSVA software on my single cell data (i am treating cells as samples). It requires this format:
I know there is a package scGSVA but it doesnt have the full functionality i have in GSVA package.
GSVA: https://bioconductor.statistik.tu-dortmund.de/packages/3.16/bioc/vignettes/GSVA/inst/doc/GSVA.html#6_Example_applications
Hi, here the GSVA maintainer, the current release version of GSVA (1.50.2) running on Bioconductor 3.18 released on October 2023 started giving support to
SingleCellExperiment
objects, which will improve in the next release of the package to come on May 1st, 2024. Seehelp(gsvaParam)
andclass ? GsvaExprData
. You can usesessionInfo()
to check the version of GSVA that you're using and if you are unsure about how to update the software, please consult https://bioconductor.org/install.That are great news! Thank you. However, we only have R version 4.1. So we can only run bioconductor version 3.14. I believe: https://bioconductor.org/about/release-announcements/
Is there any easier way I havent thought about?
Well, you can extract the matrix of normalized expression values from the Seurat object and provide that matrix to the
gsva()
function, assuming that such a matrix fits in the main memory of your hardware. If it would be too large, you can try to filter out lowly-expressed genes, which is a good practice anyway, and also try converting that matrix into a sparse matrix withMatrix::Matrix(x, sparse=TRUE)
, because I think that version of GSVA should already be able to acceptdgCMatrix
objects. In any case, for GSVA or any other Bioconductor package, it is strongly recommended to work with the latest release of the software, not only to be able to use the latest feature, but also because bugfixes and documentation improvements happen throughout releases.Thank you very much. I converted it to a matrix and used the gsva() function. However, I dont know how to deal with the metadata then. I have two groups of patients (e.g control / treated). Thanks for all your input!
In addition to above comment: I have installed now locally R Studio with appropriate R version. I was able to ran gsva on a SingleCellExperiment and got these results:
I dont find any information on how to extract now my enrichment scores for a SingleCellExperiment. Can you please clarify? I would like to do a heatmap with two copykat_pred metadata categories included. Similar to this one:
https://bioconductor.org/packages/devel/bioc/vignettes/GSVA/inst/doc/GSVA.html#6_Example_applications
A
SingleCellExperiment
object is inherited from aSummarizedExperiment
object, so many, or maybe all, of the getter methods for aSummarizedExperiment
object work on aSingleCellExperiment
object. The GSVA scores are return in an assay calledes
, since this is they first and only assay in your returned object, you can write the following instruction to retrieve the GSVA scores:where
x
should be the name of theSingleCellExperiment
object. Regarding how to retrieve the metadata, if it was part of the inputSingleCellExperiment
object, then it should also be part of the output object, and again applies the same principle I described before, you should be able to retrieve it writing:I recommend you taking a look at the vignettes of the packages
SummarizedExperiment
andSingleCellExperiment
to get acquainted with how to pull out the different bits of data and metadata that these types of object store. ```Thank you so much. This is extremely helpful. I have been searching for a while now.
Please apologise one final question - when running this
which dataslot is it taking form the SingleCellExperiment? I believe I should input normalised data (which should be the logcounts slot (=data slot in Seurat object)) into gsvaParam. Is it taking the normalised data?
Try:
If you do not specify an assay, it will by default use the first one, i.e.
assays(SingleCellExperiment)[[1]]
.Thank you. I tried this but get the following warning even though I have logcounts assay:
Oops, sorry, that's unexpected... but I haven't tested on objects from
Seurat::as.SingleCellExperiment()
so far...Could you please let me know the output of:
and
And is that data set publicly available so I could use it for testing? Thanks!
The dataset is not publicly available.
Thanks a lot!
Sorry again -- improved support for sparse matrices and
SingleCellExperiment
is currently under development and hence a bit of a moving target. I have found that this issue is already fixed in what is currently the development version of GSVA but not in the release (1.50.2) that you are using. We have just uploaded the fix as version 1.50.3 and it is now on its way to the Bioconductor release.If you want to use it immediately, you can try installing it from GitHub using:
and let us know if it still doesn't work for you.
Thanks I will try it asap. Do you think using counts or logcounts for 1 sample (one individual) will change gsva results much?
The GSVA method expects input data to be normalized and needs at least 10 samples, if you just have one sample you may try using the ssGSEA method.
okay, but the results I am seeing are what I would expect already (I am using it to double check some results from copykat). Is there a manual for the ssGSEA method? Thanks again for all your support today.
You should ask in the official support mailing list for ssGSEA, which I believe is this Google Group. Please search first whether they answered already your question and try to be very precise about what you want to calculate.
This thread is now too long and became off-topic with respect to your original question, so if you have further questions about GSVA please write a new post and make sure the term
GSVA
is included as a tag. Thanks for using GSVA!Yes, I have.
Maybe take a look at
Seurat::as.SingleCellExperiment()