1
$\begingroup$

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?

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
  • $\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$ – hua Dec 19 '19 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 the reduction arg, I've updated my answer. $\endgroup$ – Kohl Kinning Dec 19 '19 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$ – hua Dec 20 '19 at 1:00
  • $\begingroup$ If I understand your question correctly, replace reduction = "pca" with reduction = "umap". You'll also have to keep more dims when you do RunUMAP(), the default is to keep two. Be sure to add dims.keep = 5L to RunUMAP() 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$ – Kohl Kinning Dec 20 '19 at 19:03

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.