dot plot split by issue
0
0
Entering edit mode
17 months ago
Andy ▴ 120

Hello everyone,

I am trying to make a graph, similar to the supplementary figure 2b in this file: https://static-content.springer.com/esm/art%3A10.1038%2Fs41467-020-17740-1/MediaObjects/41467_2020_17740_MOESM1_ESM.pdf.

I suppose my code should be like:

pdf(file='byconditiontop10.pdf',width=20) DotPlot(data, features =c("DCN", "COL1A2", "CFD", "KLRB1" ), split.by="condition")+ theme(axis.text.x = > > > element_text(angle = 90))

But I received following error:

Error in DotPlot(data, features = c("DCN", "COL1A2", : ge, Monocytes, Basal cell, Acinar, bcell, Not enough colors for the number of groups

I hope you guys could give me some advices how to deal with issue.

Best Andy

dotplot seurat R • 3.1k views
ADD COMMENT
1
Entering edit mode

How many conditions do you have? According to the following GitHub issue https://github.com/satijalab/seurat/issues/1414 if you have more than two groups defined in your split.by variable then you need to provide a vector of colors.

and the DotPlot documentation states

cols   Colors to plot: the name of a palette from RColorBrewer::brewer.pal.info, a pair of colors defining a gradient, or 3+ colors defining multiple gradients (if split.by is set)
ADD REPLY
0
Entering edit mode

I have 5 conditions. So I should add collar command? like >cols=c("lightgrey", "red")

ADD REPLY
0
Entering edit mode

pdf(file='bystudytop10.pdf',width=20) features <- c("DCN", "COL1A2", "CFD", "KLRB1", "CD7", "GZMK", "MT1G", "MT1H", "MT1F" ) DotPlot(data, features=features, split.by="study", col=c("#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#800080", "#FFA500", "#FFC0CB", "#00FFFF", "#A52A2A", "#000000"))+ theme(axis.text.x = element_text(angle = 90)) dev.off()

My study included 10 different studies, and I add the color command, but the system still saying there are some error with my code.

Error in DotPlot(data, features = features, split.by = "study", col = c("#FF0000", : argument 4 matches multiple formal arguments

I think I might should not add color like this?

ADD REPLY
1
Entering edit mode

the color parameter is cols not col, can you try again after editing your code?

Also, don't use ">" to format you text as a code block, use a triple back tick like "```". For more markdown formatting details, see https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#styling-text

ADD REPLY
0
Entering edit mode

It worked! Thank you so much!

ADD REPLY
0
Entering edit mode

Could you create a minimal example using something like colab?

https://colab.research.google.com/notebook#create=true&language=r

ADD REPLY

Login before adding your answer.

Traffic: 2575 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6