4
$\begingroup$

I am working with single-cell RNA-seq data, using the R package "Seurat" to cluster and visual data-points.

I had two single cell datasets from which I generated two Seurat objects. I then combined the two using MergeSeurat. I did differential gene expression analysis, performed clustering, and ran a tSNE plot.

Now what I want to do is create that same tSNE plot, but color each cell according to the original object from which it came. How do I do this?

$\endgroup$
  • $\begingroup$ When asking for help, you should include a simple reproducible example with sample input and desired output that can be used to test and verify possible solutions $\endgroup$ – MrFlick Oct 2 '18 at 15:38
  • $\begingroup$ @MrFlick Don’t you agree that it’s a fairly clear question for domain experts (which, according to your profile, you are)? I’ve flagged it to be moved to bioinformatics.SE. $\endgroup$ – Konrad Rudolph Oct 2 '18 at 15:56
  • 1
    $\begingroup$ @KonradRudolph It would be even more clear with an example that I copy copy/paste to test with. Often I help people with packages I've never used before because they include an example that I can play with to get it working. And I don't like answering questions only to have an OP say "this doesn't work with my data"; which happens a lot. So it's just easier to help someone and verify a solution works if a reproducible example is provided. In my opinion there is no question that wouldn't benefit from a reproducible example. $\endgroup$ – MrFlick Oct 2 '18 at 16:03
2
$\begingroup$

Below a few lines of code that accompany BC Wang's answer. After using MergeSeurat the sample name will be added to meta data under orig.ident. this can then be used to color the tSNE either using group.by or pt.shape. The former will show colors for each sample, the latter will color each cluster and give sample id another shape.

path1 <- file.path("path to 10x sample 1")
path2 <- file.path("path to 10x sample 2")

S1 <- Read10X(data.dir = path1)
S2 <- Read10X(data.dir = path2)
S1 <- CreateSeuratObject(raw.data = S1, min.cells = 3, project = "S1")
S2 <- CreateSeuratObject(raw.data = S2, min.cells = 3, project = "S2")

s.combined <- MergeSeurat(object1 = S1, object2 = S2, add.cell.id1 = "S1", 
            add.cell.id2 = "S2", project = "2samples")

All data analysis goes here: RunTSNE etc...

Plot the data

TSNEPlot(s.combined, group.by ="orig.ident")
TSNEPlot(s.combined, pt.shape="orig.ident")
$\endgroup$
1
$\begingroup$

If I understand your question correctly, you are trying to present the tSNE plot coloring and labeling the cells representations based on the original sample ID, i.e. which Seurat object it was from.

I think they offered a vignette on that. Please check this link. https://satijalab.org/seurat/merge_vignette.html

Basically, you can add the sample name for the cells in the argument option in MergeSeurat function. Please check the documentation on MergeSeurat function as well.

When I did this, I have a lot of samples to be merged, so I simply saved the sample info for every cell in each sample to different objects. You can also use AddMetadata to do it as well.

Hope that helps.

$\endgroup$
0
$\begingroup$

It is impossible to create the same tSNE plot without knowing which seed you used. tSNE plots are not like PCAs you don't get the same results when using the same data.

But if you want another tSNE plot with a color differentiating from which object each sample comes you'll need a column with these information and color the plot by it.

$\endgroup$
  • $\begingroup$ Seurat allows you to visualize tSNE plots with gene expression data painted on top using the FeaturePlot function. I assume there must be a way to do the same thing with meta data such as original IDs. I just can't find anything online that shows how to do this. $\endgroup$ – David Tatarakis Oct 3 '18 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.