Skip to content

Commit

Permalink
added lables to plots
Browse files Browse the repository at this point in the history
  • Loading branch information
warthmann committed Nov 18, 2019
1 parent 715b738 commit 06445ca
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rules/denovo.rules.smk
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ rule pca_mash:
output:
"output/plots/denovo/mash/pca.pdf",
script:
"../scripts/pca.R"
"../scripts/pca_mash.R"

rule pca_kwip:
input:
rules.kwip.input,
output:
"output/plots/denovo/kwip/pca.pdf",
script:
"../scripts/pca.R"
"../scripts/pca_kwip.R"



Expand Down
3 changes: 3 additions & 0 deletions scripts/pca.R → scripts/pca_kwip.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ print (snakemake@output[[1]])

y0<-read.delim(snakemake@input[[1]], header=T)
data<-as.matrix(y0[, -1])
labels<-colnames(data)
pca <- prcomp(data, scale=F)
print ('PCA done!')
plot3d(pca$x[,c(1,2,3)], size=10)
text3d(pca$x[,c(1,2,3)], text=labels)
rgl.postscript(snakemake@output[[1]],"pdf")
rgl.postscript(snakemake@output[[1]],"svg")

15 changes: 15 additions & 0 deletions scripts/pca_mash.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
library(rgl)

print (snakemake@input[[1]])
print (snakemake@output[[1]])

y0<-read.delim(snakemake@input[[1]], header=T)
data<-as.matrix(y0[, -1])
labels<-as.data.frame(do.call(rbind, strsplit(colnames(data), "[.]")))$V4
pca <- prcomp(data, scale=F)
print ('PCA done!')
plot3d(pca$x[,c(1,2,3)], size=10)
text3d(pca$x[,c(1,2,3)], text=labels)
rgl.postscript(snakemake@output[[1]],"pdf")
rgl.postscript(snakemake@output[[1]],"svg")

0 comments on commit 06445ca

Please sign in to comment.