<p>By default, <a href="https://www.rdocumentation.org/packages/Seurat/versions/3.1.4/topics/DimPlot" rel="nofollow noreferrer"><code>DimPlot</code></a> colors the cells by their "identity class", stored in <code>Ident(scData)</code> in your case. This indeed contains the clustering information.</p>

<p>However, you can you use the <code>group.by</code> argument for <code>DimPlot</code> to pass another column from <code>scData@meta.data</code> to color cells by. In your case you would need a metadata column that stores the <em>ptx</em>/<em>human</em> information.</p>

<p>The <a href="https://satijalab.org/seurat/v3.1/merge_vignette.html" rel="nofollow noreferrer"><code>merge</code></a> function automatically stores the original "project" information of the individual Seurat objects that you combine under <code>orig.ident</code> in the metadata. Since you set the project names to either <code>"ptx"</code> or <code>"human"</code>, the <code>orig.ident</code> column should contain the information you need.</p>

<p>Something like this should work:</p>

<pre class="lang-r prettyprint-override"><code>DimPlot(scData, reduction = "umap", group.by = "orig.ident", label = TRUE)
</code></pre>

CC BY-SA 4.0
2020-05-22T08:59:04.577Z
2020-05-22T08:59:04.577Z
milanmlft
<p>I'm trying to create a umap for single cell data from human samples and ptx samples. I can get the umap to where it shows the umap with the different clusters but I want to show where the ptx samples are and where the human samples are. </p>

<p>My code is as follows:</p>

<pre><code>#create the Seurat object

OD_10K_HUMAN &lt;- CreateSeuratObject(counts = HUMAN_OD_10K.data, min.cells = 0, project = "human")
SD_5K_HUMAN &lt;- CreateSeuratObject(counts = HUMAN_SD_5K.data, min.cells = 0, project = "human")
BNL.5K &lt;- CreateSeuratObject(counts = SD_BNL_5K.data, min.cells = 0, project = "ptx")
BNL.10K &lt;- CreateSeuratObject(counts = OD_BNL_10K.data, min.cells = 0, project = "ptx")
BNM.10K &lt;- CreateSeuratObject(counts = OD_BNM_10K.data, min.cells = 0, project = "ptx")
BNM.5K &lt;- CreateSeuratObject(counts = SD_BNM_5K.data, min.cells = 0, project = "ptx")

#merge data
scData &lt;- merge(BNL.10K, y = c(BNL.5K, BNM.10K, BNM.5K, SD_5K_HUMAN, OD_10K_HUMAN), add.cell.ids = c("A", "B", "C", "D", "E", "F"), project = "HTB2876")

mark the mito genes
mito.genes &lt;- grep(pattern = "^MT-", x = rownames(x = scData), value = TRUE)
length(mito.genes)
scData[["percent.mt"]] &lt;- PercentageFeatureSet(scData, pattern = "^MT-")

scData[["log_nCount_RNA"]] &lt;- log2(scData[["nCount_RNA"]]+1)

# remove cells with &lt;200 RNA molecules, or &gt;6000 molecules, or &gt;30% mito
scData &lt;- subset(scData, subset = nFeature_RNA &gt; 200 &amp; nFeature_RNA &lt; 6000 &amp; percent.mt &lt; 30)
scData &lt;- NormalizeData(scData, normalization.method = "LogNormalize", scale.factor = 10000)
scData &lt;- FindVariableFeatures(scData, selection.method = "vst", nfeatures = 2000)

all.genes &lt;- rownames(scData)
scData &lt;- ScaleData(scData, features = VariableFeatures(object = scData), vars.to.regress = c("nCount_RNA"))
scData &lt;- RunPCA(scData, features = VariableFeatures(object = scData))
#DimPlot(scData, reduction = "pca")

numPC = 20
scData &lt;- FindNeighbors(scData, dims = 1:numPC)
scData &lt;- FindClusters(scData, resolution = 0.4)
scData &lt;- RunUMAP(scData, dims = 1:numPC)

DimPlot(scData, reduction = "umap", label = TRUE)
</code></pre>

<scrnaseq><seurat><umap>
umap highlighting two different models
# umap highlighting two different models

(Asked by: username_0 on 2020-04-02)

I'm trying to create a umap for single cell data from human samples and ptx samples. I can get the umap to where it shows the umap with the different clusters but I want to show where the ptx samples are and where the human samples are. 
My code is as follows:
#create the Seurat object

OD_10K_HUMAN <- CreateSeuratObject(counts = HUMAN_OD_10K.data, min.cells = 0, project = "human")
SD_5K_HUMAN <- CreateSeuratObject(counts = HUMAN_SD_5K.data, min.cells = 0, project = "human")
BNL.5K <- CreateSeuratObject(counts = SD_BNL_5K.data, min.cells = 0, project = "ptx")
BNL.10K <- CreateSeuratObject(counts = OD_BNL_10K.data, min.cells = 0, project = "ptx")
BNM.10K <- CreateSeuratObject(counts = OD_BNM_10K.data, min.cells = 0, project = "ptx")
BNM.5K <- CreateSeuratObject(counts = SD_BNM_5K.data, min.cells = 0, project = "ptx")

#merge data
scData <- merge(BNL.10K, y = c(BNL.5K, BNM.10K, BNM.5K, SD_5K_HUMAN, OD_10K_HUMAN), add.cell.ids = c("A", "B", "C", "D", "E", "F"), project = "HTB2876")

mark the mito genes
mito.genes <- grep(pattern = "^MT-", x = rownames(x = scData), value = TRUE)
length(mito.genes)
scData[["percent.mt"]] <- PercentageFeatureSet(scData, pattern = "^MT-")

scData[["log_nCount_RNA"]] <- log2(scData[["nCount_RNA"]]+1)

# remove cells with <200 RNA molecules, or >6000 molecules, or >30% mito
scData <- subset(scData, subset = nFeature_RNA > 200 & nFeature_RNA < 6000 & percent.mt < 30)
scData <- NormalizeData(scData, normalization.method = "LogNormalize", scale.factor = 10000)
scData <- FindVariableFeatures(scData, selection.method = "vst", nfeatures = 2000)

all.genes <- rownames(scData)
scData <- ScaleData(scData, features = VariableFeatures(object = scData), vars.to.regress = c("nCount_RNA"))
scData <- RunPCA(scData, features = VariableFeatures(object = scData))
#DimPlot(scData, reduction = "pca")

numPC = 20
scData <- FindNeighbors(scData, dims = 1:numPC)
scData <- FindClusters(scData, resolution = 0.4)
scData <- RunUMAP(scData, dims = 1:numPC)

DimPlot(scData, reduction = "umap", label = TRUE)

**Tags:** scrnaseq, seurat, umap

---

## 1 answers

### Answer by username_1 on 2020-05-22. Score: 1

By default, DimPlot colors the cells by their "identity class", stored in Ident(scData) in your case. This indeed contains the clustering information.
However, you can you use the group.by argument for DimPlot to pass another column from scData@meta.data to color cells by. In your case you would need a metadata column that stores the ptx/human information.
The merge function automatically stores the original "project" information of the individual Seurat objects that you combine under orig.ident in the metadata. Since you set the project names to either "ptx" or "human", the orig.ident column should contain the information you need.
Something like this should work:
DimPlot(scData, reduction = "umap", group.by = "orig.ident", label = TRUE)


---

