Entering edit mode
21 months ago
windsur
▴
20
Hello, I have downloaded the RDS file here, the "MNP-VERSE".
I am trying to extract all the cells and their value for a specific tissue in a specific gene (e.g. breast tissue and MSR1 gene). So far I get this:
library(tidyverse)
filename <- file.choose()
msr1 <-read_rds(filename)
view(subset(msr1,Tissue == 'Breast'))
I do not have experience with this kind of file, I suppose it is something like this:
view(head(Canteen_clean@assays$integrated@data@Dimnames))
But I do not know how to get it.
Any help is more than welcome! thanks
So what exactly is your question? What have you tried? Are you getting an error?
We need more information.
What I want is to get a table with the correlation of cells for a specific gene. I know how to extract the metadata for a tissue (the first
view()
), but I need to do a selection for a gene, in that case for MSR1First thing that you need to check is the class of the object that you imported to R. You can do this by running the command:
This will tell which class the R object
msr1
is. Then depending on the class, i.e.,matrix
,data.frame
,tbl
, etc, the expression that you need to use to get what you want will vary.I suspect the
msr1
is an object of classSeurat
. If so, you can look into the followingSeurat
vignettes to see how to get what you want: https://satijalab.org/seurat/articles/interaction_vignette.htmlPlease check the
vignettes
menu tab in the previous link to look into more vignettes that can help to explore this object.I hope this helps,
António
Exactly, it is
Seurat
class object. Thanks for thevignettes
. The thing is if I want to use the data attached in the link, I do not know how to filter the gene first and then selecting the correlation with cellsWell there are a couple of things that you need to know first (I'm not sure if you're familiar with them or not).
Currently I can't try to check this object due to its size. Thus everything that I'll say next are just assumptions/speculations based on other
Seurat
objects that I worked with (which not necessarily hold true for every object).In principle, in this object you've 2 assays (read more in their wiki):
RNA
andintegrated
(you can check this by doingAssays(msr1)
).They will hold slightly different information. Please check the wiki link above to get familiar with the structure of the
Seurat
object.Each of these assays may have more than one
slot
of data. In principle the assayRNA
should have theslots
:counts
(UMI counts),data
(normalized data) andscaled.data
(scaled data).In the case of the
integrated
assay, I think you should have at least the slotdata
which I think it represents batch-corrected data (please check this out).Quite often, it is recommended feature selection before performing integration, meaning that the
integrated
assay may have only a set of genes that are highly variable (quite often 2k), but not all. I don't know if this is the case. This does not seem to be the case based on the Fig.1A from the respective paper (link to the paper).Thus depending which type of assay and slot that you're interested in, you can use the function
GetAssayData(object, slot = "data", assay = NULL, ...)
to pick the gene expression data that you want.Let's say that I want the normalized data from the
RNA
assay:Since you're interested in particular genes, now you can provide that list:
You mentioned that you were interested in specific cell subsets. To select cells you can use the same logic as above:
I guess that the
@meta.data
slot contains the cell metadata where you can check the cells that you might be eventually interested in.I hope this helps,
António
Thank you so much for your advice and support. I have follow up your steps to understood how it works the Seurat objects. I wrote:
Indeed, in the metadata shows all the barcodes with its cell. Is there a way you can "change" the cell barcode of the matrix automatically?
You're welcome.
I think you are looking for the function (see function doc).
This is to rename cell barcodes in the Seurat object, but if you do it before getting the matrix, you'll get a matrix with barcodes renamed.
Otherwise you can use the function
colnames
to (re)name columns in a matrix, which in this case corresponds to cell barcodes (just be careful because once you do it they will no more correspond to the original barcodes used in the object).You can give any character vector above to rename the columns.
I hope this helps,
António