how to include color gradient for two variables
My dataset for chrom 1 looks something like this
head(data)
SNP BP P Dataset LD
1 SNP1 541095 0.00529 expression 0.000610863
2 SNP2 541095 0.07897 original 0.066610863
3 SNP3 541133 0.21990 original 0.040534557
4 SNP4 541233 0.47890 expression 0.008216450
5 SNP5 541260 0.39790 original 0.010310200
6 SNP6 541260 0.19210 expression 0.000390915
7 SNP7 541265 0.000001 original 1
7 SNP7 541265 0.00001 expression 1
I want to overlay the two datasets into one plot and also show the LD correlation of SNP7 with the other SNPs.
So far, this is what I could come up with
Position<-data$BP/1E6
ggplot(data, aes(x=Position, y=-log10(P), color=Dataset, shape=Dataset)) +
geom_point(size=4) + xlim(540101/1E6,1565570/1E6) + ylim(0,10) +
geom_hline(aes(yintercept=7), color="#a50f15")
I am not being able to group the variants according to gradient color based on LD, it shows just one color for both the datasets instead
ggplot(data, aes(x=Position, y=-log10(P), colour=LD, shape=Dataset)) +
geom_point(size=4) + xlim(540101/1E6,1565570/1E6) + ylim(0,10) +
geom_hline(aes(yintercept=7), color="#a50f15")
Is it possible to
1) Change the color of the dataset Original to red and expression to blue
2) make groups based on LD values
LD values dataset color dataset color
group1 0 to 0.2 original light blue expression light red
group2 0.2 to 0.4 original . expression .
group3 0.4 to 0.6 original . expression .
group4 0.6 to 0.8 original . expression .
group5 0.8 to 1.0 original dark blue expression dark red
Many thanks
链接地址: http://www.djcxy.com/p/30954.html上一篇: 条形图
下一篇: 如何为两个变量包含颜色渐变