خرید بک لینک

Vote count: 0

I would like to label certain points from a "box with points"-plot that is sub-grouped. The problem is that my current ggrepel code omits the sub-grouping.

Here is an example df:

Phenotype <- c("Healthy", "Healthy","Healthy", "Sick1", "Sick1","Sick1",  "Sick2", "Sick2", "Sick2" )
Individual <-c(1:9)
Genotype <- c("Nothing", "Nothing", "Nothing", "MutA", "Unknown", "MutA", "MutB", "Unknown", "Unknown")
Variable <- c("Var1", "Var1", "Var1", "Var1", "Var1", "Var1", "Var1", "Var1", "Var1")
Value <- c("1.2", "1.3", "1.3", "2.5", "2.5", "2.4", "4.1", "4.2", "4.3")
df <- data.frame(Phenotype, Individual, Genotype, Variable, Value)

And here code for the plot:

library(ggplot2)
library(ggrepel)

    ggplot (data= subset(df, Variable == "Var1"), aes(x = Phenotype, y=Value, fill=Genotype)) + geom_boxplot() + geom_dotplot(binaxis='y', stackdir='center', position=position_dodge(0.75), dotsize=0.5) + scale_fill_discrete(breaks=c("MutA","MutB","Nothing")) + labs(title= "Expression of Var1 according to Genotype", x= "Phenotype", y="Expression value")+ theme(axis.text=element_text(size=20), axis.title=element_text(size=24), plot.title = element_text(size=26, face="bold"), legend.text = element_text(size=20), legend.title = element_text(size=24)) + guides(fill=guide_legend(title="Genotype")) + geom_text_repel (data = subset(df, Genotype == "Unknown" & Variable == "Var1"), aes(label = Individual))

The df does not contain enough data points for a box plot (as I just noticed) but it still serves fine to illustrate the problem as the label for "Individual 9" is misplaced.

Thanks a lot for your help and sorry for the begiers mistakes I probably made in this question - im still leaing ;) Sebastian

enter image description here

asked 16 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 7 مرداد 1395 ساعت: 20:31

صفحه بندی