I would like to know how to change the PC use in the dimplot and featureplot by using Seurat. for we can get the x-axis and the y-axis like PC-1 and PC-2, if I want to use PC-4 and PC-5. How to modify the code?
1 Answer
$\begingroup$
$\endgroup$
4
You can choose which PC dims to plot by specifying the dims
argument within the functions. To use PC-4 and PC-5,
DimPlot(object = pbmc_small, dims = c(4, 5), reduction = "pca")
and
FeaturePlot(object = pbmc_small, features = "Xist", dims = c(4, 5), reduction = "pca")
Seurat documentation is available here.
-
$\begingroup$ Hi Kohl, thank you for your advice. But after I tried that code, I got the error:"Error in Embeddings(object = object[[reduction]])[cells, dims] : subscript out of bounds Calls: DimPlot Execution halted" Do you have any idea about this? $\endgroup$– huaCommented Dec 19, 2019 at 1:42
-
$\begingroup$ From the docs:
**reduction** Which dimensionality reduction to use. If not specified, first searches for umap, then tsne, then pca
. I imagine you haven't run UMAP or tSNE yet. Try providing thereduction
arg, I've updated my answer. $\endgroup$ Commented Dec 19, 2019 at 21:57 -
1$\begingroup$ Hi Kohl, thank you for your advice. And I have successfully got the PC change, but I would like to know whether we can change the UMPA use? like the PC use? $\endgroup$– huaCommented Dec 20, 2019 at 1:00
-
$\begingroup$ If I understand your question correctly, replace
reduction = "pca"
withreduction = "umap"
. You'll also have to keep more dims when you doRunUMAP()
, the default is to keep two. Be sure to adddims.keep = 5L
toRunUMAP()
if you want to access dims 4 and 5. If you need any more detail, you should ask another question as this has branch from your original question and would be more helpful for future seekers if it were on it's own. $\endgroup$ Commented Dec 20, 2019 at 19:03