zhengxwen / SNPRelate

R package: parallel computing toolset for relatedness and principal component analysis of SNP data (Development version only)
http://www.bioconductor.org/packages/SNPRelate
101 stars 25 forks source link

Exporting snpgdsCutTree data into a JSON format? #18

Closed brspurri closed 8 years ago

brspurri commented 8 years ago

Is there any supported (or unsupported) way to create a dendrogram using:

dissMatrix  <-  snpgdsDiss(genofile , sample.id=NULL, snp.id=NULL, autosome.only=TRUE,remove.monosnp=TRUE, maf=NaN, missing.rate=NaN, num.thread=10, verbose=TRUE)
snpHCluster <-  snpgdsHCluster(dissMatrix, sample.id=NULL, need.mat=TRUE, hang=0.25)
cutTree <- snpgdsCutTree(snpHCluster, z.threshold=15, outlier.n=5, n.perm = 5000, samp.group=NULL,col.outlier="red", col.list=NULL, pch.outlier=4, pch.list=NULL,label.H=FALSE, label.Z=TRUE, verbose=TRUE)

And export the cutTree to a hierarchial JSON format? I would love to be able to display the graphs in d3, but not sure how to go about starting the format conversions.

Does anyone have any pointers?

zhengxwen commented 8 years ago

I google "R dendrogram JSON", and find: https://gist.github.com/markvanderloo/13b4447e14e642635984

Call

s <- d3dendrogram(cutTree$dendrogram)
cat(s, file="dendrogram.html", sep="\n")

It is able to create a html file dendrogram.html to show D3 dendrogram.

brspurri commented 8 years ago

Wow, yeah, this is an awesome start. Thanks!