YinLiLin / CMplot

📊 Circular and Rectangular Manhattan Plot
502 stars 111 forks source link

Miami plot highlight SNPs #47

Open rbutleriii opened 3 years ago

rbutleriii commented 3 years ago

Hello, I ran into an issue plotting two manhattans and labeling the SNPs. If you feed it a list of SNPs for highlight.text, it will always label the first one it finds. Is there a format of the highlight vector that will highlight the upper or lower SNPs independently?

library(CMplot)
data(cattle50K)
cat2 = cattle50K
cat2[,4:ncol(cattle50K)] <- apply(cattle50K[,4:ncol(cattle50K)], 2, function(x) -x )
combined = rbind(cattle50K, cat2)

SNPs <- list(
    combined$SNP[abs(combined[[4]]) >0.01],
    combined$SNP[abs(combined[[5]]) >0.01],
    combined$SNP[abs(combined[[6]]) >0.01]
)

# plot
CMplot(combined, type="h",plot.type="m", band=0.5, LOG10=FALSE, ylab="SNP effect",ylim=c(-0.02,0.02),
        threshold.lty=2, threshold.lwd=1, threshold.col="red", amplify=FALSE,cex=0.6,
        chr.den.col=NULL, file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE, highlight=SNPs, 
        highlight.text=SNPs, highlight.col=NULL)

combined[combined$SNP %in% SNPs[[2]],]
#            SNP chr     pos Somatic cell score  Milk yield Fat percentage
# 25086 SNP25086  14 1366897        0.002724654  0.01134473     0.01725977
# 25088 SNP25088  14 1464533       -0.002148450 -0.01407219    -0.02303989
# 25089 SNP25089  14 1513351       -0.001374140  0.01087308     0.01652615
# 25090 SNP25090  14 1562168       -0.001105026  0.01048968    -0.01615920
# 25091 SNP25091  14 1610986       -0.001838383 -0.01435086     0.02367300
# 25093 SNP25093  14 1708622        0.000844426  0.01322645     0.01960535
# 25102 SNP25102  14 2147982        0.003561931  0.01003882    -0.01529792
# 67637 SNP25086  14 1366897       -0.002724654 -0.01134473    -0.01725977
# 67639 SNP25088  14 1464533        0.002148450  0.01407219     0.02303989
# 67640 SNP25089  14 1513351        0.001374140 -0.01087308    -0.01652615
# 67641 SNP25090  14 1562168        0.001105026 -0.01048968     0.01615920
# 67642 SNP25091  14 1610986        0.001838383  0.01435086    -0.02367300
# 67644 SNP25093  14 1708622       -0.000844426 -0.01322645    -0.01960535
# 67653 SNP25102  14 2147982       -0.003561931 -0.01003882     0.01529792

Rectangular-Manhattan Milk yield