我有一个数据集,其中不同的基因型经历了不同的测试条件。这些是在多个不同的队列中完成的。因此,我想制作一个点图,以区分不同的基因型。我还希望每个基因型组中的每个点都有一种颜色,代表它们来自哪个同类群组。
我创建了一个数据集作为示例:
Y<-c(2,3,1,6,4,5,3,3,4)
X<-c('test','test','test','test','control','control','control','test','control')
Cohort <- c("first", "Second", "Second", "Second", "Second", "first", "Second","Second", "first")
Genotype<-c("WT","WT","WT","Mutant","Mutant","Mutant","Mutant","WT","WT")
DF<-data.frame(X,Y,Cohort,Genotype)
DF
ggplot(DF, aes(x=X, y=Y, group= X:Genotype)) +
geom_dotplot(binaxis = "y", stackdir = "center", binwidth = 0.5, stroke= 3, aes(colour= Genotype, fill = Cohort), position = position_dodge(1)) +
scale_fill_manual(values = c("light blue", "blue"))+
scale_color_manual(values = c("orange", "purple"))
执行此代码时,我得到一个类似于所需图形的图形。但是,有些点将留空,而不是根据同类群组进行着色。
Here is the graph with some dots unfilled.
谢谢您的帮助!