Mercurial > repos > genouest > askor_de
comparison AskoR.R @ 2:f7dde9cca31e draft default tip
planemo upload for repository https://github.com/genouest/galaxy-tools/tree/master/tools/askor commit 994ecff7807bb0eb9dac740d67ad822415b0b464
| author | genouest |
|---|---|
| date | Thu, 19 Apr 2018 03:44:16 -0400 |
| parents | d24096d4c002 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:ea4a79798dcf | 2:f7dde9cca31e |
|---|---|
| 276 print(table(ASKO_stat$Expression)) | 276 print(table(ASKO_stat$Expression)) |
| 277 colnames(ASKOlist$stat.table)[colnames(ASKOlist$stat.table)=="gene"] <- paste("is", "gene", sep="@") # header formatting for askomics | 277 colnames(ASKOlist$stat.table)[colnames(ASKOlist$stat.table)=="gene"] <- paste("is", "gene", sep="@") # header formatting for askomics |
| 278 colnames(ASKOlist$stat.table)[colnames(ASKOlist$stat.table)=="contrast"] <- paste("measured_in", "Contrast", sep="@") # header formatting for askomics | 278 colnames(ASKOlist$stat.table)[colnames(ASKOlist$stat.table)=="contrast"] <- paste("measured_in", "Contrast", sep="@") # header formatting for askomics |
| 279 o <- order(ASKOlist$stat.table$FDR) # ordering genes by FDR value | 279 o <- order(ASKOlist$stat.table$FDR) # ordering genes by FDR value |
| 280 ASKOlist$stat.table<-ASKOlist$stat.table[o,] | 280 ASKOlist$stat.table<-ASKOlist$stat.table[o,] |
| 281 | |
| 281 # | 282 # |
| 282 dir.create(parameters$out_dir) | 283 dir.create(parameters$out_dir) |
| 283 write.table(ASKOlist$stat.table,paste0(parameters$out_dir,"/", parameters$organism, contrasko, ".txt"), # | 284 write.table(ASKOlist$stat.table,paste0(parameters$out_dir,"/", parameters$organism, contrasko, ".txt"), # |
| 284 sep=parameters$sep, col.names = T, row.names = F, quote=FALSE) | 285 sep=parameters$sep, col.names = T, row.names = F, quote=FALSE) |
| 285 | 286 |
| 287 | |
| 286 if(parameters$heatmap==TRUE){ | 288 if(parameters$heatmap==TRUE){ |
| 287 cpm_gstats<-cpm(dge, log=TRUE)[o,][1:parameters$numhigh,] | 289 numhigh=parameters$numhigh |
| 290 if (numhigh>length(o)) {numhigh=length(o)} | |
| 291 cpm_gstats<-cpm(dge, log=TRUE)[o,][1:numhigh,] | |
| 288 heatmap.2(cpm_gstats, cexRow=0.5, cexCol=0.8, scale="row", labCol=dge$samples$Name, xlab=contrast, Rowv = FALSE, dendrogram="col") | 292 heatmap.2(cpm_gstats, cexRow=0.5, cexCol=0.8, scale="row", labCol=dge$samples$Name, xlab=contrast, Rowv = FALSE, dendrogram="col") |
| 289 } | 293 } |
| 290 | 294 |
| 291 return(ASKOlist) | 295 return(ASKOlist) |
| 292 | 296 |
| 360 count<-read.table(parameters$fileofcount, header=TRUE, sep = "\t", row.names = parameters$col_genes, comment.char = "") | 364 count<-read.table(parameters$fileofcount, header=TRUE, sep = "\t", row.names = parameters$col_genes, comment.char = "") |
| 361 } | 365 } |
| 362 select_counts<-row.names(samples) | 366 select_counts<-row.names(samples) |
| 363 #countT<-count[,c(parameters$col_counts:length(colnames(count)))] | 367 #countT<-count[,c(parameters$col_counts:length(colnames(count)))] |
| 364 countT<-count[,select_counts] | 368 countT<-count[,select_counts] |
| 369 #print(countT) | |
| 365 dge<-DGEList(counts=countT, samples=samples) | 370 dge<-DGEList(counts=countT, samples=samples) |
| 366 # if(is.null(parameters$select_sample)==FALSE){ | 371 # if(is.null(parameters$select_sample)==FALSE){ |
| 367 # slct<-grep(parameters$select_sample, colnames(countT)) | 372 # slct<-grep(parameters$select_sample, colnames(countT)) |
| 368 # countT<-countT[,slct] | 373 # countT<-countT[,slct] |
| 369 # } | 374 # } |
| 478 cex=0.5) | 483 cex=0.5) |
| 479 return(filtered_counts) | 484 return(filtered_counts) |
| 480 } | 485 } |
| 481 | 486 |
| 482 GEnorm <- function(filtered_GE, parameters){ | 487 GEnorm <- function(filtered_GE, parameters){ |
| 483 filtered_cpm <- cpm(filtered_GE, log=TRUE) #nouveau calcul Cpm sur donn?es filtr?es, si log=true alors valeurs cpm en log2 | 488 filtered_cpm=log2(1000000*filtered_GE$counts/colSums(filtered_GE$counts)) |
| 489 #filtered_cpm <- cpm(filtered_GE, log=TRUE, normalized.lib.sizes=TRUE) #nouveau calcul Cpm sur donn?es filtr?es, si log=true alors valeurs cpm en log2 | |
| 484 colnames(filtered_cpm)<-rownames(filtered_GE$samples) | 490 colnames(filtered_cpm)<-rownames(filtered_GE$samples) |
| 485 boxplot(filtered_cpm, | 491 boxplot(filtered_cpm, |
| 486 col=filtered_GE$samples$color, #boxplot des scores cpm non normalis?s | 492 col=filtered_GE$samples$color, #boxplot des scores cpm non normalis?s |
| 487 main="A. Before normalization", | 493 main="A. Before normalization", |
| 488 cex.axis=0.5, | 494 cex.axis=0.5, |
| 507 lcpm<-cpm(dge, log=TRUE) | 513 lcpm<-cpm(dge, log=TRUE) |
| 508 colnames(lcpm)<-rownames(dge$samples) | 514 colnames(lcpm)<-rownames(dge$samples) |
| 509 cormat<-cor(lcpm) | 515 cormat<-cor(lcpm) |
| 510 # color<- colorRampPalette(c("yellow", "white", "green"))(20) | 516 # color<- colorRampPalette(c("yellow", "white", "green"))(20) |
| 511 color<-colorRampPalette(c("black","red","yellow","white"),space="rgb")(28) | 517 color<-colorRampPalette(c("black","red","yellow","white"),space="rgb")(28) |
| 512 heatmap(cormat, col=color, symm=TRUE,RowSideColors =as.character(dge$samples$color), ColSideColors = as.character(dge$samples$color)) | 518 heatmap.2(cormat, col=color, symm=TRUE,RowSideColors =as.character(dge$samples$color), ColSideColors = as.character(dge$samples$color)) |
| 513 #MDS | 519 #MDS |
| 514 mds <- cmdscale(dist(t(lcpm)),k=3, eig=TRUE) | 520 mds <- cmdscale(dist(t(lcpm)),k=3, eig=TRUE) |
| 515 eigs<-round((mds$eig)*100/sum(mds$eig[mds$eig>0]),2) | 521 eigs<-round((mds$eig)*100/sum(mds$eig[mds$eig>0]),2) |
| 516 | 522 |
| 517 mds1<-ggplot(as.data.frame(mds$points), aes(V1, V2, label = rownames(mds$points))) + labs(title="MDS Axes 1 and 2") + geom_point(color =as.character(dge$samples$color) ) + xlab(paste('dim 1 [', eigs[1], '%]')) +ylab(paste('dim 2 [', eigs[2], "%]")) + geom_label_repel(aes(label = rownames(mds$points)), color = 'black',size = 3.5) | 523 mds1<-ggplot(as.data.frame(mds$points), aes(V1, V2, label = rownames(mds$points))) + labs(title="MDS Axes 1 and 2") + geom_point(color =as.character(dge$samples$color) ) + xlab(paste('dim 1 [', eigs[1], '%]')) +ylab(paste('dim 2 [', eigs[2], "%]")) + geom_label_repel(aes(label = rownames(mds$points)), color = 'black',size = 3.5) |
