## Load PubChem SDFset sample
data(sdfsample); sdfset <- sdfsample
cid(sdfset) <- sdfid(sdfset)
## Convert base 64 encoded fingerprints to FPset object
fpset <- fp2bit(sdfset)
## Pairwise compound structure comparisons
fpSim(fpset[1], fpset[2])
## Structure similarity searching: x is query and y is fingerprint database
fpSim(x=fpset[1], y=fpset, method="Tanimoto", cutoff=0, top="all")
## Compute fingerprint based Tanimoto similarity matrix
simMA <- sapply(cid(fpset), function(x) fpSim(x=fpset[x], fpset, sorted=FALSE))
## Hierarchical clustering with simMA as input
hc <- hclust(as.dist(1-simMA), method="single")
## Plot hierarchical clustering tree
plot(as.dendrogram(hc), edgePar=list(col=4, lwd=2), horiz=TRUE)
Run the code above in your browser using DataLab