Mercurial > repos > galaxyp > quantp
annotate quantp.r @ 0:75faf9a89f5b draft
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
author | galaxyp |
---|---|
date | Fri, 14 Sep 2018 12:22:31 -0400 |
parents | |
children | bcc7a4c4cc29 |
rev | line source |
---|---|
0
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1 #*************************************************************************************************************************************** |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
2 # Functions: Start |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
3 #*************************************************************************************************************************************** |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
4 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
5 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
6 # PCA |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
7 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
8 multisample_PCA = function(df, sampleinfo_df, outfile) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
9 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
10 tempdf = df[,-1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
11 tempcol = colnames(tempdf); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
12 tempgrp = sampleinfo_df[tempcol,2]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
13 tempdf = t(tempdf) %>% as.data.frame(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
14 tempdf[is.na(tempdf)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
15 tempdf$Group = tempgrp; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
16 png(outfile, width = 6, height = 6, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
17 # bitmap(outfile, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
18 g = autoplot(prcomp(select(tempdf, -Group)), data = tempdf, colour = 'Group', size=3); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
19 plot(g); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
20 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
21 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
22 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
23 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
24 # Regression and Cook's distance |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
25 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
26 singlesample_regression = function(PE_TE_data,htmloutfile, append=TRUE) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
27 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
28 rownames(PE_TE_data) = PE_TE_data$PE_ID; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
29 regmodel = lm(PE_abundance~TE_abundance, data=PE_TE_data); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
30 regmodel_summary = summary(regmodel); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
31 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
32 cat("<font><h3>Linear Regression model fit between Proteome and Transcriptome data</h3></font>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
33 "<p>Assuming a linear relationship between Proteome and Transcriptome data, we here fit a linear regression model.</p>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
34 '<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Value</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
35 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
36 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
37 cat("<tr><td>Formula</td><td>","PE_abundance~TE_abundance","</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
38 "<tr><td colspan='2' align='center'> <b>Coefficients</b></td>","</tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
39 "<tr><td>",names(regmodel$coefficients[1]),"</td><td>",regmodel$coefficients[1]," (Pvalue:", regmodel_summary$coefficients[1,4],")","</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
40 "<tr><td>",names(regmodel$coefficients[2]),"</td><td>",regmodel$coefficients[2]," (Pvalue:", regmodel_summary$coefficients[2,4],")","</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
41 "<tr><td colspan='2' align='center'> <b>Model parameters</b></td>","</tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
42 "<tr><td>Residual standard error</td><td>",regmodel_summary$sigma," (",regmodel_summary$df[2]," degree of freedom)</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
43 "<tr><td>F-statistic</td><td>",regmodel_summary$fstatistic[1]," ( on ",regmodel_summary$fstatistic[2]," and ",regmodel_summary$fstatistic[3]," degree of freedom)</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
44 "<tr><td>R-squared</td><td>",regmodel_summary$r.squared,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
45 "<tr><td>Adjusted R-squared</td><td>",regmodel_summary$adj.r.squared,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
46 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
47 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
48 cat("</table>\n", file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
49 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
50 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
51 "<font color='#ff0000'><h3>Regression and diagnostics plots</h3></font>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
52 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
53 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
54 outplot = paste(outdir,"/PE_TE_lm_1.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
55 png(outplot, width = 10, height = 10, units = 'in',res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
56 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
57 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
58 plot(regmodel, 1, cex.lab=1.5); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
59 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
60 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
61 outplot = paste(outdir,"/PE_TE_lm_2.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
62 png(outplot,width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
63 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
64 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
65 plot(regmodel, 2, cex.lab=1.5); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
66 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
67 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
68 outplot = paste(outdir,"/PE_TE_lm_5.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
69 png(outplot, width = 10, height = 10, units = 'in',res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
70 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
71 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
72 plot(regmodel, 5, cex.lab=1.5); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
73 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
74 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
75 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; ">', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
76 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
77 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
78 '<tr bgcolor="#7a0019"><th>', "<font color='#ffcc33'><h4>1) <u>Residuals vs Fitted plot</h4></font></u></th>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
79 '<th><font color=#ffcc33><h4>2) <u>Normal Q-Q plot of residuals</h4></font></u></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
80 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
81 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
82 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
83 '<tr><td align=center><img src="PE_TE_lm_1.png" width=600 height=600></td><td align=center><img src="PE_TE_lm_2.png" width=600 height=600></td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
84 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
85 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
86 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
87 '<tr><td align=center>This plot checks for linear relationship assumptions.<br>If a horizontal line is observed without any distinct patterns, it indicates a linear relationship.</td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
88 '<td align=center>This plot checks whether residuals are normally distributed or not.<br>It is good if the residuals points follow the straight dashed line i.e., do not deviate much from dashed line.</td></tr></table>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
89 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
90 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
91 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
92 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
93 # Residuals data |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
94 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
95 res_all = regmodel$residuals; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
96 res_mean = mean(res_all); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
97 res_sd = sd(res_all); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
98 res_diff = (res_all-res_mean); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
99 res_zscore = res_diff/res_sd; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
100 # res_outliers = res_all[which((res_zscore > 2)|(res_zscore < -2))] |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
101 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
102 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
103 tempind = which((res_zscore > 2)|(res_zscore < -2)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
104 res_PE_TE_data_no_outlier = PE_TE_data[-tempind,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
105 res_PE_TE_data_no_outlier$residuals = res_all[-tempind]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
106 res_PE_TE_data_outlier = PE_TE_data[tempind,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
107 res_PE_TE_data_outlier$residuals = res_all[tempind]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
108 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
109 # Save the complete table for download (influential_observations) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
110 temp_outlier_data = data.frame(res_PE_TE_data_outlier$PE_ID, res_PE_TE_data_outlier$TE_abundance, res_PE_TE_data_outlier$PE_abundance, res_PE_TE_data_outlier$residuals) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
111 colnames(temp_outlier_data) = c("Gene", "Transcript abundance", "Protein abundance", "Residual value") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
112 outdatafile = paste(outdir,"/PE_TE_outliers_residuals.txt", sep="", collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
113 write.table(temp_outlier_data, file=outdatafile, row.names=F, sep="\t", quote=F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
114 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
115 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
116 # Save the complete table for download (non influential_observations) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
117 temp_all_data = data.frame(PE_TE_data$PE_ID, PE_TE_data$TE_abundance, PE_TE_data$PE_abundance, res_all) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
118 colnames(temp_all_data) = c("Gene", "Transcript abundance", "Protein abundance", "Residual value") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
119 outdatafile = paste(outdir,"/PE_TE_abundance_residuals.txt", sep="", collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
120 write.table(temp_all_data, file=outdatafile, row.names=F, sep="\t", quote=F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
121 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
122 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
123 cat('<br><h2 id="inf_obs"><font color=#ff0000>Outliers based on the residuals from regression analysis</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
124 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
125 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; ">\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
126 '<tr bgcolor="#7a0019"><th colspan=2><font color=#ffcc33>Residuals from Regression</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
127 '<tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Value</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
128 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
129 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
130 cat("<tr><td>Mean Residual value</td><td>",res_mean,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
131 "<tr><td>Standard deviation (Residuals)</td><td>",res_sd,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
132 '<tr><td>Total outliers (Residual value > 2 standard deviation from the mean)</td><td>',length(tempind),' <font size=4>(<b><a href=PE_TE_outliers_residuals.txt target="_blank">Download these ',length(tempind),' data points with high residual values here</a></b>)</font></td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
133 '<tr><td colspan=2 align=center><font size=4>(<b><a href=PE_TE_abundance_residuals.txt target="_blank">Download the complete residuals data here</a></b>)</font></td></td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
134 "</table><br><br>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
135 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
136 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
137 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
138 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
139 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
140 cat('<br><br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; ">', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
141 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
142 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
143 '<tr bgcolor="#7a0019"><th><font color=#ffcc33><h4>3) <u>Residuals vs Leverage plot</h4></font></u></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
144 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
145 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
146 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
147 '<tr><td align=center><img src="PE_TE_lm_5.png" width=600 height=600></td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
148 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
149 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
150 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
151 '<tr><td align=center>This plot is useful to identify any influential cases, that is outliers or extreme values.<br>They might influence the regression results upon inclusion or exclusion from the analysis.</td></tr></table><br>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
152 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
153 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
154 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
155 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
156 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
157 # Cook's Distance |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
158 #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
159 cat('<hr/><h2 id="inf_obs"><font color=#ff0000>INFLUENTIAL OBSERVATIONS</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
160 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
161 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
162 '<p><b>Cook\'s distance</b> computes the influence of each data point/observation on the predicted outcome. i.e. this measures how much the observation is influencing the fitted values.<br>In general use, those observations that have a <b>Cook\'s distance > than ', cookdist_upper_cutoff,' times the mean</b> may be classified as <b>influential.</b></p>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
163 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
164 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
165 cooksd <- cooks.distance(regmodel); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
166 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
167 outplot = paste(outdir,"/PE_TE_lm_cooksd.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
168 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
169 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
170 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
171 plot(cooksd, main="Influential Obs. by Cook\'s distance", ylab="Cook\'s distance", xlab="Observations", type="n") # plot cooks distance |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
172 sel_outlier=which(cooksd>=as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
173 sel_nonoutlier=which(cooksd<as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
174 points(sel_outlier, cooksd[sel_outlier],pch="*", cex=2, cex.lab=1.5, col="red") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
175 points(sel_nonoutlier, cooksd[sel_nonoutlier],pch="*", cex=2, cex.lab=1.5, col="black") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
176 abline(h = as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T), col="red") # add cutoff line |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
177 #text(x=1:length(cooksd)+1, y=cooksd, labels=ifelse(cooksd>as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T),names(cooksd),""), col="red", pos=2) # add labels |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
178 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
179 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
180 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
181 '<img src="PE_TE_lm_cooksd.png" width=800 height=800>', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
182 '<br>In the above plot, observations above red line (',cookdist_upper_cutoff,' * mean Cook\'s distance) are influential. Genes that are outliers could be important. These observations influences the correlation values and regression coefficients<br><br>', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
183 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
184 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
185 tempind = which(cooksd>as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
186 PE_TE_data_no_outlier = PE_TE_data[-tempind,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
187 PE_TE_data_no_outlier$cooksd = cooksd[-tempind]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
188 PE_TE_data_outlier = PE_TE_data[tempind,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
189 PE_TE_data_outlier$cooksd = cooksd[tempind]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
190 a = sort(PE_TE_data_outlier$cooksd, decreasing=T, index.return=T); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
191 PE_TE_data_outlier_sorted = PE_TE_data_outlier[a$ix,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
192 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
193 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
194 '<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Value</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
195 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
196 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
197 # Save the complete table for download (influential_observations) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
198 temp_outlier_data = data.frame(PE_TE_data_outlier$PE_ID, PE_TE_data_outlier$TE_abundance, PE_TE_data_outlier$PE_abundance, PE_TE_data_outlier$cooksd) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
199 colnames(temp_outlier_data) = c("Gene", "Transcript abundance", "Protein abundance", "Cook's distance") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
200 outdatafile = paste(outdir,"/PE_TE_influential_observation.txt", sep="", collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
201 write.table(temp_outlier_data, file=outdatafile, row.names=F, sep="\t", quote=F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
202 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
203 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
204 # Save the complete table for download (non influential_observations) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
205 temp_no_outlier_data = data.frame(PE_TE_data_no_outlier$PE_ID, PE_TE_data_no_outlier$TE_abundance, PE_TE_data_no_outlier$PE_abundance, PE_TE_data_no_outlier$cooksd) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
206 colnames(temp_no_outlier_data) = c("Gene", "Transcript abundance", "Protein abundance", "Cook's distance") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
207 outdatafile = paste(outdir,"/PE_TE_non_influential_observation.txt", sep="", collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
208 write.table(temp_no_outlier_data, file=outdatafile, row.names=F, sep="\t", quote=F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
209 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
210 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
211 cat("<tr><td>Mean Cook\'s distance</td><td>",mean(cooksd, na.rm=T),"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
212 "<tr><td>Total influential observations (Cook\'s distance > ",cookdist_upper_cutoff," * mean Cook\'s distance)</td><td>",length(tempind),"</td>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
213 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
214 "<tr><td>Observations with Cook\'s distance < ",cookdist_upper_cutoff," * mean Cook\'s distance</td><td>",length(which(cooksd<as.numeric(cookdist_upper_cutoff)*mean(cooksd, na.rm=T))),"</td>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
215 "</table><br><br>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
216 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
217 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
218 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
219 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
220 # Scatter plot after removal of influential points |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
221 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
222 outplot = paste(outdir,"/AbundancePlot_scatter_without_outliers.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
223 min_lim = min(c(PE_TE_data$PE_abundance,PE_TE_data$TE_abundance)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
224 max_lim = max(c(PE_TE_data$PE_abundance,PE_TE_data$TE_abundance)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
225 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
226 # bitmap(outplot,"png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
227 g = ggplot(PE_TE_data_no_outlier, aes(x=TE_abundance, y=PE_abundance))+geom_point() + geom_smooth() + xlab("Transcript abundance log fold-change") + ylab("Protein abundance log fold-change") + xlim(min_lim,max_lim) + ylim(min_lim,max_lim); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
228 suppressMessages(plot(g)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
229 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
230 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
231 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Scatterplot: Before removal</font></th><th><font color=#ffcc33>Scatterplot: After removal</font></th></tr>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
232 # Before |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
233 cat("<tr><td align=center><!--<font color='#ff0000'><h3>Scatter plot between Proteome and Transcriptome Abundance</h3></font>\n-->", '<img src="TE_PE_scatter.png" width=600 height=600></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
234 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
235 # After |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
236 cat("<td align=center>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
237 '<img src="AbundancePlot_scatter_without_outliers.png" width=600 height=600></td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
238 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
239 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
240 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
241 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
242 cor_result_pearson = cor.test(PE_TE_data_no_outlier[,"TE_abundance"], PE_TE_data_no_outlier[,"PE_abundance"], method = "pearson"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
243 cor_result_spearman = cor.test(PE_TE_data_no_outlier[,"TE_abundance"], PE_TE_data_no_outlier[,"PE_abundance"], method = "spearman"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
244 cor_result_kendall = cor.test(PE_TE_data_no_outlier[,"TE_abundance"], PE_TE_data_no_outlier[,"PE_abundance"], method = "kendall"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
245 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
246 cat('<tr><td>\n', file = htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
247 singlesample_cor(PE_TE_data, htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
248 cat('</td>\n', file = htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
249 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
250 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
251 cat('<td><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Method 1</font></th><th><font color=#ffcc33>Method 2</font></th><th><font color=#ffcc33>Method 3</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
252 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
253 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
254 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
255 "<tr><td>Correlation method</td><td>",cor_result_pearson$method,"</td><td>",cor_result_spearman$method,"</td><td>",cor_result_kendall$method,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
256 "<tr><td>Correlation coefficient</td><td>",cor_result_pearson$estimate,"</td><td>",cor_result_spearman$estimate,"</td><td>",cor_result_kendall$estimate,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
257 file = htmloutfile, append = TRUE) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
258 cat("</table></td></tr></table>\n", file = htmloutfile, append = TRUE) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
259 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
260 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
261 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
262 if(dim(PE_TE_data_outlier)[1]<10) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
263 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
264 tab_n_row = dim(PE_TE_data_outlier)[1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
265 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
266 tab_n_row = 10; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
267 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
268 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
269 cat("<br><br><font size=5><b><a href='PE_TE_influential_observation.txt' target='_blank'>Download the complete list of influential observations</a></b></font> ", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
270 "<font size=5><b><a href='PE_TE_non_influential_observation.txt' target='_blank'>Download the complete list (After removing influential points)</a></b></font><br>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
271 '<br><font color="brown"><h4>Top ',as.character(tab_n_row),' Influential observations (Cook\'s distance > ',cookdist_upper_cutoff,' * mean Cook\'s distance)</h4></font>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
272 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
273 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
274 cat('<table border=1 cellspacing=0 cellpadding=5> <tr bgcolor="#7a0019">\n', sep = "",file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
275 cat("<th><font color=#ffcc33>Gene</font></th><th><font color=#ffcc33>Protein Log Fold-Change</font></th><th><font color=#ffcc33>Transcript Log Fold-Change</font></th><th><font color=#ffcc33>Cook's Distance</font></th></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
276 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
277 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
278 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
279 for(i in 1:tab_n_row) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
280 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
281 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
282 '<tr>','<td>',as.character(PE_TE_data_outlier_sorted[i,1]),'</td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
283 '<td>',format(PE_TE_data_outlier_sorted[i,2], scientific=F),'</td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
284 '<td>',PE_TE_data_outlier_sorted[i,4],'</td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
285 '<td>',format(PE_TE_data_outlier_sorted[i,5], scientific=F),'</td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
286 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
287 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
288 cat('</table><br><br>\n',file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
289 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
290 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
291 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
292 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
293 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
294 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
295 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
296 # Heatmap |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
297 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
298 singlesample_heatmap=function(PE_TE_data, htmloutfile, hm_nclust){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
299 cat('<br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Heatmap of PE and TE abundance values (Hierarchical clustering)</font></th><th><font color=#ffcc33>Number of clusters to extract: ',hm_nclust,'</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
300 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
301 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
302 hc=hclust(dist(as.matrix(PE_TE_data[,c("PE_abundance","TE_abundance")]))) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
303 hm_cluster = cutree(hc,k=hm_nclust); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
304 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
305 outplot = paste(outdir,"/PE_TE_heatmap.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
306 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
307 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
308 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
309 hmap = heatmap.2(as.matrix(PE_TE_data[,c("PE_abundance","TE_abundance")]), trace="none", cexCol=1, col=greenred(100),Colv=F, labCol=c("Proteins","Transcripts"), scale="col", hclustfun = hclust, distfun = dist); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
310 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
311 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
312 cat('<tr><td align=center colspan="2"><img src="PE_TE_heatmap.png" width=800 height=800></td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
313 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
314 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
315 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
316 temp_PE_TE_data = data.frame(PE_TE_data$PE_ID, PE_TE_data$TE_abundance, PE_TE_data$PE_abundance, hm_cluster); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
317 colnames(temp_PE_TE_data) = c("Gene", "Transcript abundance", "Protein abundance", "Cluster (Hierarchical clustering)") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
318 tempoutfile = paste(outdir,"/PE_TE_hc_clusterpoints.txt",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
319 write.table(temp_PE_TE_data, file=tempoutfile, row.names=F, quote=F, sep="\t", eol="\n") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
320 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
321 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
322 cat('<tr><td colspan="2" align=center><font size=5><a href="PE_TE_hc_clusterpoints.txt" target="_blank"><b>Download the hierarchical cluster list</b></a></font></td></tr></table>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
323 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
324 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
325 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
326 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
327 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
328 # K-means clustering |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
329 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
330 singlesample_kmeans=function(PE_TE_data, htmloutfile, nclust){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
331 PE_TE_data_kdata = PE_TE_data; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
332 k1 = kmeans(PE_TE_data_kdata[,c("PE_abundance","TE_abundance")], nclust); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
333 outplot = paste(outdir,"/PE_TE_kmeans.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
334 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
335 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
336 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
337 scatter.smooth(PE_TE_data_kdata[,"TE_abundance"], PE_TE_data_kdata[,"PE_abundance"], xlab="Transcript Abundance", ylab="Protein Abundance", cex.lab=1.5); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
338 legend(1, 95, legend=c("Cluster 1", "Line 2"), col="red", lty=1:1, cex=0.8) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
339 legend(1, 95, legend="Cluster 2", col="green", lty=1:1, cex=0.8) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
340 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
341 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
342 ind=which(k1$cluster==1); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
343 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="red", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
344 ind=which(k1$cluster==2); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
345 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="green", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
346 ind=which(k1$cluster==3); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
347 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="blue", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
348 ind=which(k1$cluster==4); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
349 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="cyan", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
350 ind=which(k1$cluster==5); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
351 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="black", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
352 ind=which(k1$cluster==6); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
353 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="brown", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
354 ind=which(k1$cluster==7); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
355 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="gold", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
356 ind=which(k1$cluster==8); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
357 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="thistle", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
358 ind=which(k1$cluster==9); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
359 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="yellow", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
360 ind=which(k1$cluster==10); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
361 points(PE_TE_data_kdata[ind,"TE_abundance"], PE_TE_data_kdata[ind,"PE_abundance"], col="orange", pch=16); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
362 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
363 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
364 cat('<br><br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>K-mean clustering</font></th><th><font color=#ffcc33>Number of clusters: ',nclust,'</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
365 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
366 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
367 tempind = order(k1$cluster); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
368 tempoutfile = paste(outdir,"/PE_TE_kmeans_clusterpoints.txt",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
369 write.table(data.frame(PE_TE_data_kdata[tempind, ], Cluster=k1$cluster[tempind]), file=tempoutfile, row.names=F, quote=F, sep="\t", eol="\n") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
370 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
371 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
372 cat('<tr><td colspan="2" align=center><img src="PE_TE_kmeans.png" width=800 height=800></td></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
373 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
374 cat('<tr><td colspan="2" align=center><font size=5><a href="PE_TE_kmeans_clusterpoints.txt" target="_blank"><b>Download the cluster list</b></a></font></td></tr></table><br><hr/>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
375 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
376 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
377 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
378 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
379 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
380 # scatter plot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
381 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
382 singlesample_scatter = function(PE_TE_data, outfile) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
383 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
384 min_lim = min(c(PE_TE_data$PE_abundance,PE_TE_data$TE_abundance)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
385 max_lim = max(c(PE_TE_data$PE_abundance,PE_TE_data$TE_abundance)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
386 png(outfile, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
387 # bitmap(outfile, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
388 g = ggplot(PE_TE_data, aes(x=TE_abundance, y=PE_abundance))+geom_point() + geom_smooth() + xlab("Transcript abundance log fold-change") + ylab("Protein abundance log fold-change") + xlim(min_lim,max_lim) + ylim(min_lim,max_lim); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
389 suppressMessages(plot(g)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
390 # plot(g); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
391 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
392 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
393 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
394 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
395 # Correlation table |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
396 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
397 singlesample_cor = function(PE_TE_data, htmloutfile, append=TRUE) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
398 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
399 cor_result_pearson = cor.test(PE_TE_data$TE_abundance, PE_TE_data$PE_abundance, method = "pearson"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
400 cor_result_spearman = cor.test(PE_TE_data$TE_abundance, PE_TE_data$PE_abundance, method = "spearman"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
401 cor_result_kendall = cor.test(PE_TE_data$TE_abundance, PE_TE_data$PE_abundance, method = "kendall"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
402 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
403 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
404 '<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Parameter</font></th><th><font color=#ffcc33>Method 1</font></th><th><font color=#ffcc33>Method 2</font></th><th><font color=#ffcc33>Method 3</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
405 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
406 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
407 cat( |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
408 "<tr><td>Correlation method</td><td>",cor_result_pearson$method,"</td><td>",cor_result_spearman$method,"</td><td>",cor_result_kendall$method,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
409 "<tr><td>Correlation coefficient</td><td>",cor_result_pearson$estimate,"</td><td>",cor_result_spearman$estimate,"</td><td>",cor_result_kendall$estimate,"</td></tr>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
410 file = htmloutfile, append = TRUE) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
411 cat("</table>\n", file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
412 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
413 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
414 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
415 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
416 # Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
417 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
418 multisample_boxplot = function(df, sampleinfo_df, outfile, fill_leg, user_xlab, user_ylab) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
419 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
420 tempdf = df[,-1, drop=FALSE]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
421 tempdf = t(tempdf) %>% as.data.frame(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
422 tempdf[is.na(tempdf)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
423 tempdf$Sample = rownames(tempdf); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
424 tempdf1 = melt(tempdf, id.vars = "Sample"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
425 tempdf1$Group = sampleinfo_df[tempdf1$Sample,2]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
426 png(outplot, width = 6, height = 6, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
427 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
428 if(fill_leg=="Yes") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
429 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
430 g = ggplot(tempdf1, aes(x=Sample, y=value, fill=Group)) + geom_boxplot() + labs(x=user_xlab) + labs(y=user_ylab) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
431 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
432 if(fill_leg=="No") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
433 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
434 tempdf1$Group = c("case", "control") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
435 g = ggplot(tempdf1, aes(x=Sample, y=value, fill=Group)) + geom_boxplot() + labs(x=user_xlab) + labs(y=user_ylab) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
436 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
437 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
438 plot(g); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
439 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
440 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
441 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
442 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
443 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
444 # Mean or Median of Replicates |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
445 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
446 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
447 mergeReplicates = function(TE_df,PE_df, sampleinfo_df, method) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
448 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
449 grps = unique(sampleinfo_df[,2]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
450 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
451 TE_df_merged <<- sapply(grps, function(x){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
452 tempsample = sampleinfo_df[which(sampleinfo_df$Group==x),1] |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
453 if(length(tempsample)!=1){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
454 apply(TE_df[,tempsample],1,method); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
455 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
456 return(TE_df[,tempsample]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
457 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
458 }); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
459 TE_df_merged <<- data.frame(as.character(TE_df[,1]), TE_df_merged); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
460 colnames(TE_df_merged) = c(colnames(TE_df)[1], grps); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
461 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
462 PE_df_merged <<- sapply(grps, function(x){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
463 tempsample = sampleinfo_df[which(sampleinfo_df$Group==x),1] |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
464 if(length(tempsample)!=1){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
465 apply(PE_df[,tempsample],1,method); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
466 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
467 return(PE_df[,tempsample]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
468 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
469 }); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
470 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
471 PE_df_merged <<- data.frame(as.character(PE_df[,1]), PE_df_merged); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
472 colnames(PE_df_merged) = c(colnames(PE_df)[1], grps); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
473 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
474 #sampleinfo_df_merged = data.frame(Sample = grps, Group = grps, stringsAsFactors = F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
475 sampleinfo_df_merged = data.frame(Sample = grps, Group = "Group", stringsAsFactors = F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
476 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
477 return(list(TE_df_merged = TE_df_merged, PE_df_merged = PE_df_merged, sampleinfo_df_merged = sampleinfo_df_merged)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
478 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
479 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
480 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
481 # (T-Test or Wilcoxon ranksum test) and Volcano Plot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
482 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
483 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
484 perform_Test_Volcano = function(TE_df_data,PE_df_data,TE_df_logfold, PE_df_logfold,sampleinfo_df, method, correction_method,volc_with) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
485 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
486 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
487 PE_colnames = colnames(PE_df_data); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
488 control_sample = sampleinfo_df[which(sampleinfo_df$Group=="control"),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
489 control_ind <<- sapply(control_sample, function(x){temp_ind = which(PE_colnames==x); as.numeric(temp_ind)}); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
490 condition_sample = sampleinfo_df[which(sampleinfo_df$Group=="case"),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
491 condition_ind <<- sapply(condition_sample, function(x){temp_ind = which(PE_colnames==x); as.numeric(temp_ind)}); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
492 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
493 if(method=="mean"){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
494 #PE_pval = apply(PE_df_data[2:length(colnames(PE_df_data))],1,function(x) t.test(x[condition_ind-1], x[control_ind-1])$p.value); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
495 PE_pval = apply(PE_df_data[2:length(colnames(PE_df_data))],1,function(x) {obj<-try(t.test(x[condition_ind-1], x[control_ind-1]),silent=TRUE); if(is(obj, "try-error")){return(NA)}else{return(obj$p.value)}}) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
496 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
497 if(method=="median"){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
498 PE_pval = apply(PE_df_data[2:length(colnames(PE_df_data))],1,function(x) {obj<-try(wilcox.test(x[condition_ind-1], x[control_ind-1]),silent=TRUE); if(is(obj, "try-error")){return(NA)}else{return(obj$p.value)}}) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
499 # PE_pval = apply(PE_df_data[2:length(colnames(PE_df_data))],1,function(x) wilcox.test(x[condition_ind-1], x[control_ind-1])$p.value); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
500 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
501 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
502 PE_adj_pval = p.adjust(PE_pval, method = correction_method, n = length(PE_pval)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
503 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
504 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
505 TE_colnames = colnames(TE_df_data); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
506 control_sample = sampleinfo_df[which(sampleinfo_df$Group=="control"),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
507 control_ind <<- sapply(control_sample, function(x){temp_ind = which(TE_colnames==x); as.numeric(temp_ind)}); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
508 condition_sample = sampleinfo_df[which(sampleinfo_df$Group=="case"),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
509 condition_ind <<- sapply(condition_sample, function(x){temp_ind = which(TE_colnames==x); as.numeric(temp_ind)}); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
510 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
511 if(method=="mean"){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
512 # TE_pval = apply(TE_df_data[2:length(colnames(TE_df_data))],1,function(x) t.test(x[condition_ind-1], x[control_ind-1])$p.value); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
513 TE_pval = apply(TE_df_data[2:length(colnames(TE_df_data))],1,function(x) {obj<-try(t.test(x[condition_ind-1], x[control_ind-1]),silent=TRUE); if(is(obj, "try-error")){return(NA)}else{return(obj$p.value)}}) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
514 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
515 if(method=="median"){ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
516 TE_pval = apply(TE_df_data[2:length(colnames(TE_df_data))],1,function(x) {obj<-try(wilcox.test(x[condition_ind-1], x[control_ind-1]),silent=TRUE); if(is(obj, "try-error")){return(NA)}else{return(obj$p.value)}}) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
517 # TE_pval = apply(TE_df_data[2:length(colnames(TE_df_data))],1,function(x) wilcox.test(x[condition_ind-1], x[control_ind-1])$p.value); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
518 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
519 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
520 TE_adj_pval = p.adjust(TE_pval, method = correction_method, n = length(TE_pval)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
521 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
522 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
523 PE_TE_logfold_pval = data.frame(TE_df_logfold$Gene, TE_df_logfold$LogFold, TE_pval, TE_adj_pval, PE_df_logfold$LogFold, PE_pval, PE_adj_pval); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
524 colnames(PE_TE_logfold_pval) = c("Gene", "Transcript log fold-change", "p-value (transcript)", "adj p-value (transcript)", "Protein log fold-change", "p-value (protein)", "adj p-value (protein)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
525 outdatafile = paste(outdir,"/PE_TE_logfold_pval.txt", sep="", collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
526 write.table(PE_TE_logfold_pval, file=outdatafile, row.names=F, sep="\t", quote=F); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
527 cat("<br><br><font size=5><b><a href='PE_TE_logfold_pval.txt' target='_blank'>Download the complete fold change data here</a></b></font><br>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
528 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
529 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
530 if(length(condition_ind)!=1) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
531 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
532 # Volcano Plot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
533 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
534 if(volc_with=="adj_pval") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
535 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
536 PE_pval = PE_adj_pval |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
537 TE_pval = TE_adj_pval |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
538 volc_ylab = "-log10 Adjusted p-value"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
539 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
540 if(volc_with=="pval") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
541 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
542 volc_ylab = "-log10 p-value"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
543 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
544 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
545 outplot = paste(outdir,"/PE_volcano.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
546 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
547 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
548 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
549 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
550 plot(PE_df_logfold$LogFold, -log10(PE_pval), |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
551 xlab="log2 fold change", ylab=volc_ylab, |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
552 type="n") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
553 sel <- which((PE_df_logfold$LogFold<=log(2,base=2))&(PE_df_logfold$LogFold>=log(0.5, base=2))) # or whatever you want to use |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
554 points(PE_df_logfold[sel,"LogFold"], -log10(PE_pval[sel]),col="black") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
555 #sel <- which((PE_df_logfold$LogFold>log(2,base=2))&(PE_df_logfold$LogFold<log(0.5,base=2))) # or whatever you want to use |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
556 sel <- which((PE_df_logfold$LogFold>log(2,base=2))|(PE_df_logfold$LogFold<log(0.5, base=2))) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
557 sel1 <- which(PE_pval<=0.05) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
558 sel=intersect(sel,sel1) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
559 points(PE_df_logfold[sel,"LogFold"], -log10(PE_pval[sel]),col="red") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
560 sel <- which((PE_df_logfold$LogFold>log(2,base=2))|(PE_df_logfold$LogFold<log(0.5, base=2))) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
561 sel1 <- which(PE_pval>0.05) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
562 sel=intersect(sel,sel1) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
563 points(PE_df_logfold[sel,"LogFold"], -log10(PE_pval[sel]),col="blue") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
564 abline(h = -log(0.05,base=10), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
565 abline(v = log(2,base=2), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
566 abline(v = log(0.5,base=2), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
567 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
568 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
569 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
570 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
571 outplot = paste(outdir,"/TE_volcano.png",sep="",collapse=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
572 png(outplot, width = 10, height = 10, units = 'in', res=300); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
573 # bitmap(outplot, "png16m"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
574 par(mfrow=c(1,1)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
575 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
576 plot(TE_df_logfold$LogFold, -log10(TE_pval), |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
577 xlab="log2 fold change", ylab=volc_ylab, |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
578 type="n") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
579 sel <- which((TE_df_logfold$LogFold<=log(2,base=2))&(TE_df_logfold$LogFold>=log(0.5, base=2))) # or whatever you want to use |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
580 points(TE_df_logfold[sel,"LogFold"], -log10(TE_pval[sel]),col="black") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
581 #sel <- which((TE_df_logfold$LogFold>log(2,base=2))&(TE_df_logfold$LogFold<log(0.5,base=2))) # or whatever you want to use |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
582 sel <- which((TE_df_logfold$LogFold>log(2,base=2))|(TE_df_logfold$LogFold<log(0.5, base=2))) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
583 sel1 <- which(TE_pval<=0.05) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
584 sel=intersect(sel,sel1) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
585 points(TE_df_logfold[sel,"LogFold"], -log10(TE_pval[sel]),col="red") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
586 sel <- which((TE_df_logfold$LogFold>log(2,base=2))|(TE_df_logfold$LogFold<log(0.5, base=2))) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
587 sel1 <- which(TE_pval>0.05) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
588 sel=intersect(sel,sel1) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
589 points(TE_df_logfold[sel,"LogFold"], -log10(TE_pval[sel]),col="blue") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
590 abline(h = -log(0.05,base=10), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
591 abline(v = log(2,base=2), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
592 abline(v = log(0.5,base=2), col="red", lty=2) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
593 dev.off(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
594 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
595 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
596 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
597 cat('<br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Transcript Fold-Change</font></th><th><font color=#ffcc33>Protein Fold-Change</font></th></tr>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
598 cat("<tr><td align=center>", '<img src="TE_volcano.png" width=600 height=600></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
599 cat("<td align=center>", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
600 '<img src="PE_volcano.png" width=600 height=600></td></tr></table><br>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
601 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
602 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
603 cat('<br><br><b><font color=red>!!! No replicates found. Cannot perform test to check significance of differential expression. Thus, no Volcano plot generated !!!</font></b><br><br>', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
604 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
605 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
606 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
607 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
608 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
609 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
610 #*************************************************************************************************************************************** |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
611 # Functions: End |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
612 #*************************************************************************************************************************************** |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
613 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
614 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
615 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
616 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
617 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
618 # Arguments |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
619 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
620 noargs = 12; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
621 args = commandArgs(trailingOnly = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
622 if(length(args) != noargs) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
623 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
624 stop(paste("Please check usage. Number of arguments is not equal to ",noargs,sep="",collapse="")); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
625 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
626 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
627 mode = args[1]; # "multiple" or "logfold" |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
628 method = args[2]; # "mean" or "median" |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
629 sampleinfo_file = args[3]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
630 proteome_file = args[4]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
631 transcriptome_file = args[5]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
632 correction_method = args[6]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
633 cookdist_upper_cutoff = args[7]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
634 numCluster = args[8]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
635 hm_nclust = args[9]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
636 volc_with = args[10]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
637 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
638 htmloutfile = args[11]; # html output file |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
639 outdir = args[12]; # html supporting files |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
640 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
641 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
642 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
643 # Check for file existance |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
644 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
645 if(! file.exists(proteome_file)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
646 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
647 stop(paste("Proteome Data file does not exists. Path given: ",proteome_file,sep="",collapse="")); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
648 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
649 if(! file.exists(transcriptome_file)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
650 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
651 stop(paste("Transcriptome Data file does not exists. Path given: ",transcriptome_file,sep="",collapse="")); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
652 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
653 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
654 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
655 # Load library |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
656 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
657 options(warn=-1); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
658 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
659 suppressPackageStartupMessages(library(dplyr)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
660 suppressPackageStartupMessages(library(data.table)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
661 suppressPackageStartupMessages(library(gplots)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
662 suppressPackageStartupMessages(library(ggplot2)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
663 suppressPackageStartupMessages(library(ggfortify)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
664 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
665 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
666 # Select mode and parse experiment design file |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
667 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
668 if(mode=="multiple") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
669 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
670 expDesign = fread(sampleinfo_file, header = FALSE, stringsAsFactors = FALSE, sep="\t") %>% data.frame(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
671 expDesign_cc = expDesign[1:2,]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
672 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
673 sampleinfo_df = expDesign[3:nrow(expDesign),]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
674 rownames(sampleinfo_df)=1:nrow(sampleinfo_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
675 colnames(sampleinfo_df) = c("Sample","Group"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
676 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
677 condition_cols = sampleinfo_df[which(sampleinfo_df[,2]==expDesign_cc[which(expDesign_cc[,1]=="case"),2]),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
678 condition_g_name = "case"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
679 control_cols = sampleinfo_df[which(sampleinfo_df[,2]==expDesign_cc[which(expDesign_cc[,1]=="control"),2]),1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
680 control_g_name = "control"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
681 sampleinfo_df[which(sampleinfo_df[,2]==expDesign_cc[which(expDesign_cc[,1]=="case"),2]),2] = "case"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
682 sampleinfo_df[which(sampleinfo_df[,2]==expDesign_cc[which(expDesign_cc[,1]=="control"),2]),2] = "control"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
683 sampleinfo_df_orig = sampleinfo_df; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
684 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
685 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
686 if(mode=="logfold") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
687 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
688 sampleinfo_df = data.frame("Sample"= c("LogFold"), "Group"=c("Fold_Change")) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
689 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
690 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
691 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
692 # Parse Transcriptome data |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
693 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
694 TE_df_orig = fread(transcriptome_file, sep="\t", stringsAsFactor=F, header=T) %>% data.frame(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
695 if(mode=="multiple") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
696 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
697 TE_df = TE_df_orig[,c(colnames(TE_df_orig)[1],condition_cols,control_cols)]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
698 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
699 if(mode=="logfold") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
700 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
701 TE_df = TE_df_orig; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
702 colnames(TE_df) = c("Genes", "LogFold"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
703 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
704 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
705 # Parse Proteome data |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
706 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
707 PE_df_orig = fread(proteome_file, sep="\t", stringsAsFactor=F, header=T) %>% data.frame(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
708 if(mode=="multiple") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
709 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
710 PE_df = PE_df_orig[,c(colnames(PE_df_orig)[1],condition_cols,control_cols)]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
711 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
712 if(mode=="logfold") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
713 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
714 PE_df = PE_df_orig; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
715 colnames(PE_df) = c("Genes", "LogFold"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
716 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
717 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
718 #============================================================================================================= |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
719 # Create directory structures and then set the working directory to output directory |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
720 #============================================================================================================= |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
721 if(! file.exists(outdir)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
722 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
723 dir.create(outdir); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
724 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
725 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
726 # Write initial data summary in html outfile |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
727 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
728 cat("<html><head></head><body>\n", file = htmloutfile); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
729 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
730 cat("<h1><u>QuanTP: Association between abundance ratios of transcript and protein</u></h1><hr/>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
731 "<font><h3>Input data summary</h3></font>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
732 "<ul>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
733 "<li>Abbreviations used: PE (Proteome data) and TE (Transcriptome data)","</li><br>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
734 "<li>Input Proteome data dimension (Row Column): ", dim(PE_df)[1]," x ", dim(PE_df)[2],"</li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
735 "<li>Input Transcriptome data dimension (Row Column): ", dim(TE_df)[1]," x ", dim(TE_df)[2],"</li></ul><hr/>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
736 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
737 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
738 cat("<h3 id=table_of_content>Table of Contents:</h3>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
739 "<ul>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
740 "<li><a href=#sample_dist>Sample distribution</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
741 "<li><a href=#corr_data>Correlation</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
742 "<li><a href=#regression_data>Regression analysis</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
743 "<li><a href=#inf_obs>Influential observations</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
744 "<li><a href=#cluster_data>Cluster analysis</a></li></ul><hr/>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
745 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
746 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
747 # Find common samples |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
748 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
749 common_samples = intersect(sampleinfo_df[,1], colnames(TE_df)[-1]) %>% intersect(., colnames(PE_df)[-1]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
750 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
751 if(length(common_samples)==0) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
752 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
753 stop("No common samples found "); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
754 cat("<b>Please check your experiment design file. Sample names (column names) in the Transcriptome and the Proteome data do not match. </b>\n",file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
755 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
756 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
757 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
758 # Create subsets based on common samples |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
759 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
760 TE_df = select(TE_df, 1, common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
761 PE_df = select(PE_df, 1, common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
762 sampleinfo_df = filter(sampleinfo_df, Sample %in% common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
763 rownames(sampleinfo_df) = sampleinfo_df[,1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
764 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
765 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
766 # Check for number of rows similarity |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
767 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
768 if(nrow(TE_df) != nrow(PE_df)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
769 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
770 stop("Number of rows in Transcriptome and Proteome data are not same i.e. they are not paired"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
771 cat("<b>The correlation analysis expects paired TE and PE data i.e. (i)th gene/transcript of TE file should correspond to (i)th protein of PE file. In the current input provided there is mismatch in terms of number of rows of TE and PE file. Please make sure you provide paired data.</b>\n",file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
772 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
773 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
774 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
775 # Number of groups |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
776 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
777 ngrps = unique(sampleinfo_df[,2]) %>% length(); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
778 grps = unique(sampleinfo_df[,2]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
779 names(grps) = grps; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
780 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
781 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
782 # Change column1 name |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
783 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
784 colnames(TE_df)[1] = "Gene"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
785 colnames(PE_df)[1] = "Protein"; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
786 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
787 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
788 # Treat missing values |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
789 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
790 TE_nacount = sum(is.na(TE_df)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
791 PE_nacount = sum(is.na(PE_df)); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
792 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
793 TE_df[is.na(TE_df)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
794 PE_df[is.na(PE_df)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
795 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
796 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
797 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
798 # Decide based on analysis mode |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
799 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
800 if(mode=="logfold") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
801 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
802 cat('<h2 id="sample_dist"><font color=#ff0000>SAMPLE DISTRIBUTION</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
803 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
804 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
805 # TE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
806 outplot = paste(outdir,"/Box_TE.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
807 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; ">\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
808 '<tr bgcolor="#7a0019"><th><font color=#ffcc33>Boxplot: Transcriptome data</font></th><th><font color=#ffcc33>Boxplot: Proteome data</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
809 "<tr><td align=center>", '<img src="Box_TE.png" width=500 height=500></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
810 multisample_boxplot(TE_df, sampleinfo_df, outplot, "Yes", "Samples", "Transcript Abundance data"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
811 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
812 # PE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
813 outplot = paste(outdir,"/Box_PE.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
814 cat("<td align=center>", '<img src="Box_PE.png" width=500 height=500></td></tr></table>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
815 multisample_boxplot(PE_df, sampleinfo_df, outplot, "Yes", "Samples", "Protein Abundance data"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
816 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
817 cat('<hr/><h2 id="corr_data"><font color=#ff0000>CORRELATION</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
818 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
819 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
820 # TE PE scatter |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
821 outplot = paste(outdir,"/TE_PE_scatter.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
822 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Scatter plot between Proteome and Transcriptome Abundance</font></th></tr>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
823 cat("<tr><td align=center>", '<img src="TE_PE_scatter.png" width=800 height=800></td></tr>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
824 PE_TE_data = data.frame(PE_df, TE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
825 colnames(PE_TE_data) = c("PE_ID","PE_abundance","TE_ID","TE_abundance"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
826 singlesample_scatter(PE_TE_data, outplot); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
827 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
828 # TE PE Cor |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
829 cat("<tr><td align=center>", file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
830 singlesample_cor(PE_TE_data, htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
831 cat('<font color="red">*Note that <u>correlation</u> is <u>sensitive to outliers</u> in the data. So it is important to analyze outliers/influential observations in the data.<br> Below we use <u>Cook\'s distance based approach</u> to identify such influential observations.</font>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
832 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
833 cat('</td></table>', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
834 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
835 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
836 cat('<hr/><h2 id="regression_data"><font color=#ff0000>REGRESSION ANALYSIS</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
837 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
838 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
839 # TE PE Regression |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
840 singlesample_regression(PE_TE_data,htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
841 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
842 cat('<hr/><h2 id="cluster_data"><font color=#ff0000>CLUSTER ANALYSIS</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
843 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
844 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
845 # TE PE Heatmap |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
846 singlesample_heatmap(PE_TE_data, htmloutfile, hm_nclust); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
847 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
848 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
849 # TE PE Clustering (kmeans) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
850 singlesample_kmeans(PE_TE_data, htmloutfile, nclust=as.numeric(numCluster)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
851 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
852 }else{ |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
853 if(mode=="multiple") |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
854 { |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
855 cat('<h2 id="sample_dist"><font color=#ff0000>SAMPLE DISTRIBUTION</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
856 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
857 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
858 # TE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
859 outplot = paste(outdir,"/Box_TE_all_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
860 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; ">\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
861 '<tr bgcolor="#7a0019"><th><font color=#ffcc33>Boxplot: Transcriptome data</font></th><th><font color=#ffcc33>Boxplot: Proteome data</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
862 "<tr><td align=center>", '<img src="Box_TE_all_rep.png" width=500 height=500></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
863 temp_df_te_data = data.frame(TE_df[,1], log(TE_df[,2:length(TE_df)])); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
864 colnames(temp_df_te_data) = colnames(TE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
865 multisample_boxplot(temp_df_te_data, sampleinfo_df, outplot, "Yes", "Samples", "Transcript Abundance (log)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
866 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
867 # PE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
868 outplot = paste(outdir,"/Box_PE_all_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
869 cat("<td align=center>", '<img src="Box_PE_all_rep.png" width=500 height=500></td></tr></table>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
870 temp_df_pe_data = data.frame(PE_df[,1], log(PE_df[,2:length(PE_df)])); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
871 colnames(temp_df_pe_data) = colnames(PE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
872 multisample_boxplot(temp_df_pe_data, sampleinfo_df, outplot, "Yes", "Samples", "Protein Abundance (log)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
873 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
874 # Calc TE PCA |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
875 outplot = paste(outdir,"/PCA_TE_all_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
876 multisample_PCA(TE_df, sampleinfo_df, outplot); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
877 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
878 # Calc PE PCA |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
879 outplot = paste(outdir,"/PCA_PE_all_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
880 multisample_PCA(PE_df, sampleinfo_df, outplot); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
881 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
882 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
883 # Replicate mode |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
884 templist = mergeReplicates(TE_df,PE_df, sampleinfo_df, method); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
885 TE_df = templist$TE_df_merged; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
886 PE_df = templist$PE_df_merged; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
887 sampleinfo_df = templist$sampleinfo_df_merged; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
888 rownames(sampleinfo_df) = sampleinfo_df[,1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
889 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
890 # TE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
891 outplot = paste(outdir,"/Box_TE_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
892 cat('<br><font color="#ff0000"><h3>Sample wise distribution (Box plot) after using ',method,' on replicates </h3></font><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Boxplot: Transcriptome data</font></th><th><font color=#ffcc33>Boxplot: Proteome data</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
893 "<tr><td align=center>", '<img src="Box_TE_rep.png" width=500 height=500></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
894 temp_df_te_data = data.frame(TE_df[,1], log(TE_df[,2:length(TE_df)])); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
895 colnames(temp_df_te_data) = colnames(TE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
896 multisample_boxplot(temp_df_te_data, sampleinfo_df, outplot, "No", "Sample Groups", "Mean Transcript Abundance (log)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
897 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
898 # PE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
899 outplot = paste(outdir,"/Box_PE_rep.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
900 cat("<td align=center>", '<img src="Box_PE_rep.png" width=500 height=500></td></tr></table>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
901 temp_df_pe_data = data.frame(PE_df[,1], log(PE_df[,2:length(PE_df)])); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
902 colnames(temp_df_pe_data) = colnames(PE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
903 multisample_boxplot(temp_df_pe_data, sampleinfo_df, outplot, "No", "Sample Groups", "Mean Protein Abundance (log)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
904 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
905 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
906 # Calculating log fold change and running the "single" code part |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
907 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
908 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
909 TE_df = data.frame("Genes"=TE_df[,1], "LogFold"=apply(TE_df[,c(which(colnames(TE_df)==condition_g_name),which(colnames(TE_df)==control_g_name))],1,function(x) log(x[1]/x[2],base=2))); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
910 PE_df = data.frame("Genes"=PE_df[,1], "LogFold"=apply(PE_df[,c(which(colnames(PE_df)==condition_g_name),which(colnames(PE_df)==control_g_name))],1,function(x) log(x[1]/x[2],base=2))); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
911 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
912 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
913 # Treat missing values |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
914 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
915 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
916 TE_df[is.infinite(TE_df[,2]),2] = NA; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
917 PE_df[is.infinite(PE_df[,2]),2] = NA; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
918 TE_df[is.na(TE_df)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
919 PE_df[is.na(PE_df)] = 0; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
920 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
921 sampleinfo_df = data.frame("Sample"= c("LogFold"), "Group"=c("Fold_Change")) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
922 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
923 # Find common samples |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
924 #=============================================================================== |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
925 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
926 common_samples = intersect(sampleinfo_df[,1], colnames(TE_df)[-1]) %>% intersect(., colnames(PE_df)[-1]); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
927 TE_df = select(TE_df, 1, common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
928 PE_df = select(PE_df, 1, common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
929 sampleinfo_df = filter(sampleinfo_df, Sample %in% common_samples); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
930 rownames(sampleinfo_df) = sampleinfo_df[,1]; |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
931 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
932 # TE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
933 outplot = paste(outdir,"/Box_TE.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
934 cat('<br><font color="#ff0000"><h3>Distribution (Box plot) of log fold change </h3></font>', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
935 cat('<table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Boxplot: Transcriptome data</font></th><th><font color=#ffcc33>Boxplot: Proteome data</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
936 "<tr><td align=center>", '<img src="Box_TE.png" width=500 height=500></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
937 multisample_boxplot(TE_df, sampleinfo_df, outplot, "Yes", "Sample (log2(case/control))", "Transcript Abundance fold-change (log2)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
938 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
939 # PE Boxplot |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
940 outplot = paste(outdir,"/Box_PE.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
941 cat("<td align=center>", '<img src="Box_PE.png" width=500 height=500></td></tr></table>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
942 multisample_boxplot(PE_df, sampleinfo_df, outplot, "Yes", "Sample (log2(case/control))", "Protein Abundance fold-change(log2)"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
943 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
944 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
945 # Log Fold Data |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
946 perform_Test_Volcano(TE_df_orig,PE_df_orig,TE_df, PE_df,sampleinfo_df_orig,method,correction_method,volc_with) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
947 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
948 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
949 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
950 # Print PCA |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
951 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
952 cat('<br><br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>PCA plot: Transcriptome data</font></th><th><font color=#ffcc33>PCA plot: Proteome data</font></th></tr>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
953 "<tr><td align=center>", '<img src="PCA_TE_all_rep.png" width=500 height=500></td>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
954 "<td align=center>", '<img src="PCA_PE_all_rep.png" width=500 height=500></td></tr></table>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
955 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
956 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
957 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
958 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
959 cat('<hr/><h2 id="corr_data"><font color=#ff0000>CORRELATION</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
960 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
961 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
962 # TE PE scatter |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
963 outplot = paste(outdir,"/TE_PE_scatter.png",sep="",collape=""); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
964 cat('<br><table border=1 cellspacing=0 cellpadding=5 style="table-layout:auto; "> <tr bgcolor="#7a0019"><th><font color=#ffcc33>Scatter plot between Proteome and Transcriptome Abundance</font></th></tr>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
965 cat("<tr><td align=center>", '<img src="TE_PE_scatter.png" width=800 height=800></td>\n', file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
966 PE_TE_data = data.frame(PE_df, TE_df); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
967 colnames(PE_TE_data) = c("PE_ID","PE_abundance","TE_ID","TE_abundance"); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
968 singlesample_scatter(PE_TE_data, outplot); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
969 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
970 # TE PE Cor |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
971 cat("<tr><td align=center>\n", file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
972 singlesample_cor(PE_TE_data, htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
973 cat('<font color="red">*Note that <u>correlation</u> is <u>sensitive to outliers</u> in the data. So it is important to analyze outliers/influential observations in the data.<br> Below we use <u>Cook\'s distance based approach</u> to identify such influential observations.</font>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
974 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
975 cat('</td></table>', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
976 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
977 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
978 cat('<hr/><h2 id="regression_data"><font color=#ff0000>REGRESSION ANALYSIS</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
979 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
980 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
981 # TE PE Regression |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
982 singlesample_regression(PE_TE_data,htmloutfile, append=TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
983 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
984 cat('<hr/><h2 id="cluster_data"><font color=#ff0000>CLUSTER ANALYSIS</font></h2>\n', |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
985 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
986 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
987 #TE PE Heatmap |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
988 singlesample_heatmap(PE_TE_data, htmloutfile, hm_nclust); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
989 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
990 #TE PE Clustering (kmeans) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
991 singlesample_kmeans(PE_TE_data, htmloutfile, nclust=as.numeric(numCluster)) |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
992 |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
993 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
994 } |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
995 cat("<h3>Go To:</h3>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
996 "<ul>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
997 "<li><a href=#sample_dist>Sample distribution</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
998 "<li><a href=#corr_data>Correlation</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
999 "<li><a href=#regression_data>Regression analysis</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1000 "<li><a href=#inf_obs>Influential observations</a></li>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1001 "<li><a href=#cluster_data>Cluster analysis</a></li></ul>\n", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1002 "<br><a href=#>TOP</a>", |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1003 file = htmloutfile, append = TRUE); |
75faf9a89f5b
planemo upload commit a0e968c7bd2b6f7b963baeecb08f3a39e50f52d6
galaxyp
parents:
diff
changeset
|
1004 cat("</body></html>\n", file = htmloutfile, append = TRUE); |