Mercurial > repos > chemteam > bio3d_pca_visualize
annotate pca.R @ 3:eebc574b0923 draft default tip
"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit 3b99f08f22b9e0c16c0a0adc82f8c16c1a25cedf"
| author | chemteam | 
|---|---|
| date | Mon, 07 Oct 2019 12:30:37 -0400 | 
| parents | d16c1aea2333 | 
| children | 
| rev | line source | 
|---|---|
| 0 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 1 #!/usr/bin/env Rscript | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 2 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 3 options(stringAsfactors = FALSE) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 4 args <- commandArgs(trailingOnly = TRUE) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 5 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 6 library(bio3d) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 7 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 8 dcdfile <- args[1] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 9 pdbfile <- args[2] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 10 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 11 dcd <- read.dcd(dcdfile) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 12 pdb <- read.pdb(pdbfile) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 13 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 14 method <- args[3] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 15 selection <- args[4] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 16 domain <- args[5] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 17 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 18 output <- args[6] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 19 pca_plot <- args[7] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 20 pca_cluster <- args[8] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 21 pc1_rmsf <- args[9] | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 22 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 23 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 24 if (selection == "string") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 25 inds <- atom.select(pdb, string = domain) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 26 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 27 if (selection == "elety") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 28 inds <- atom.select(pdb, elety = domain) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 29 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 30 if (selection == "resid") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 31 inds <- atom.select(pdb, resid = domain) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 32 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 33 if (selection == "segid") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 34 inds <- atom.select(pdb, segid = domain) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 35 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 36 xyz <- fit.xyz(fixed=pdb$xyz, mobile=dcd, fixed.inds=inds$xyz, mobile.inds=inds$xyz) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 37 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 38 if (method == "FALSE") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 39 pc <- pca.xyz(xyz[,inds$xyz], use.svd=FALSE) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 40 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 41 if (method == "TRUE") { | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 42 pc <- pca.xyz(xyz[,inds$xyz], use.svd=TRUE) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 43 } | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 44 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 45 write.table(pc$au[,1:2:3], file = output, row.names = TRUE, col.names = FALSE, quote =FALSE, sep="\t") | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 46 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 47 png(pca_plot) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 48 plot(pc, col=bwr.colors(nrow(xyz)) ) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 49 dev.off() | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 50 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 51 png(pca_cluster) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 52 hc <- hclust(dist(pc$z[,1:2])) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 53 grps <- cutree(hc, k=2) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 54 plot(pc, col=grps) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 55 dev.off() | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 56 | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 57 png(pc1_rmsf) | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 58 plot.bio3d(pc$au[,1], ylab="PC1 (A)", xlab="Residue Position", typ="l") | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 59 points(pc$au[,2], typ="l", col="blue") | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 60 dev.off() | 
| 
d16c1aea2333
planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/tree/master/tools/bio3d commit cd0830e5e3502721fa355cc8e3fedc331201a6e4
 chemteam parents: diff
changeset | 61 | 
