Manhattan plot in VisualBasic, application of the cross platform VisualBasic in the data science area.
For start the further development, install the Microsoft VisualBasic CLI runtime first:
PM> Install-Package VB_AppFramework
and then add reference to the dll files:
- Microsoft.VisualBasic.Architecture.Framework_v3.0_22.0.76.201__8da45dcd8060cc9a.dll
- Microsoft.VisualBasic.DocumentFormat.Csv.dll
Manhattan plot
wiki: https://en.wikipedia.org/wiki/Manhattan_plot
A Manhattan plot is a type of scatter plot, usually used to display data with a large number of data-points - many of non-zero amplitude, and with a distribution of higher-magnitude values, for instance in genome-wide association studies (GWAS).[1] In GWAS Manhattan plots, genomic coordinates are displayed along the X-axis, with the negative logarithm of the association P-value for each single nucleotide polymorphism (SNP) displayed on the Y-axis, meaning that each dot on the Manhattan plot signifies a SNP. Because the strongest associations have the smallest P-values (e.g., 10−15), their negative logarithms will be the greatest (e.g., 15).
It gains its name from the similarity of such a plot to the Manhattan skyline: a profile of skyscrapers towering above the lower level "buildings" which vary around a lower height.
References
- Gibson, Greg (2010). "Hints of hidden heritability in GWAS". Nature Genetics. 42 (7): 558–560. doi:10.1038/ng0710-558. PMID 20581876.
Using the code
First, peeks of the test data. By using sampleTest.R
script for generates the test data set.
size <- 5000
Chr = sample(1:24,size,replace=T)
Position = sample(1:247249719,size)
sample1 = runif(size)
sample2 = runif(size)
sample3 = runif(size)
sample4 = runif(size)
sample5 = runif(size)
sample6 = runif(size)
df <- data.frame(Chr, Position, sample1, sample2, sample3, sample4, sample5, sample6)
write.csv(df, "./manhattan_plot_test.csv")
df <- read.csv("./manhattan_plot_test.csv")
head(df)
And then load data into memory by using code
Imports Microsoft.VisualBasic.DocumentFormat.Csv
Dim data As SNP() = "./manhattan_plot_test.csv".LoadCsv(Of SNP)
Canvas drawing of the Manhattan Plot
is super easy by using just one function:
Canvas.Plot(System.Collections.Generic.IEnumerable(Of ManhattanPlot.SNP), Integer, Integer, System.Collections.Generic.Dictionary(Of String, String), System.Drawing.Size, Integer, Boolean, Boolean, Boolean, String, String) As System.Drawing.Bitmap
Color patterns
Save image method extension required of imports namespace:
Imports Microsoft.VisualBasic.Imaging
Dim image As Bitmap = data.Plot(colorPattern:="chr")
Call image.SaveAs("./manhattan_plot_test.png", ImageFormats.Png)
Dim image As Bitmap = data.Plot(colorPattern:="sampleName")
Call image.SaveAs("./manhattan_plot_test_sampleName.png", ImageFormats.Png)
Dim image As Bitmap = data.Plot(colorPattern:="interval")
Call image.SaveAs("./manhattan_plot_test_interval.png", ImageFormats.Png)
Test on Linux
This program have been test successfully on the Ubuntu Linux system and Windows10, here is the test script example that you can found in the demo Resources
folder:
rm ./manhattan_plot_test_chr.png
rm ./manhattan_plot_test_interval.png
rm ./manhattan_plot_test_SampleName.png
../ManhattanPlot.exe /Draw /in "./manhattan_plot_test.csv" /pt.size 10 /sampleColors "./SampleColors.csv" /colorpattern SampleName
../ManhattanPlot.exe /Draw /in "./manhattan_plot_test.csv" /pt.size 10 /colorpattern chr
../ManhattanPlot.exe /Draw /in "./manhattan_plot_test.csv" /pt.size 10 /colorpattern interval