Skip to content

Commit

Permalink
Merge pull request #1 from ConesaLab/1.0.1
Browse files Browse the repository at this point in the history
tappAS v1.0.1
  • Loading branch information
psalguerog authored May 12, 2020
2 parents 09fd371 + 0a99c01 commit 87d7749
Show file tree
Hide file tree
Showing 10 changed files with 738,120 additions and 145 deletions.
3 changes: 2 additions & 1 deletion SubTabDFIResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,11 @@ protected Void call() throws Exception {
lst.add("-r" + r);
}
lst.add("-s" + dfiParams.sigValue);
lst.add("-x" + project.data.getMatrixDFIFilepath(analysisId));
lst.add("-c" + project.data.getDFITotalFeaturesFilepath(analysisId));
lst.add("-g1" + project.data.getDFITestFeaturesFilepath(analysisId));
lst.add("-g2" + project.data.getDFITestGenesFilepath(analysisId));

lst.add("-x" + project.data.getMatrixDFIFilepath(analysisId));
lst.add("-lt" + trans);
lst.add("-lp" + proteins);

Expand Down
2 changes: 1 addition & 1 deletion Tappas.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class Tappas extends Application {
public static final String APP_NAME = "tappas";
public static final int APP_MAJOR_VER = 1;
public static final int APP_MINOR_VER = 0;
public static final int APP_STRREV = 0;
public static final int APP_STRREV = 1;
public static final String RES_VER_FILE = "resource_v" + APP_MAJOR_VER + "." + APP_MINOR_VER + "." + APP_STRREV + ".txt";
public static final String APP_LOCK_FILE = ".tappas.lock.prm";
public static final String APP_PORT_PARAM = "port";
Expand Down
608,643 changes: 608,643 additions & 0 deletions resources/go.obo

Large diffs are not rendered by default.

60,088 changes: 60,088 additions & 0 deletions resources/hs_ncbi_genes.tsv

Large diffs are not rendered by default.

69,103 changes: 69,103 additions & 0 deletions resources/mm_ncbi_genes.tsv

Large diffs are not rendered by default.

Empty file added resources/resource_v1.0.1.txt
Empty file.
2 changes: 1 addition & 1 deletion resources/web/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<div style="background-color:white; padding:10px;">

<b>Contact:</b>
If you want to contact us to report a problem we recommend you to visit our website <a href="http://app.tappas.org/contact">http://app.tappas.org/contact</a> or send an email to <b>[email protected]</b>.
If you want to contact us to report a problem we recommend you to visit our website <a href="http://app.tappas.org/contact">http://app.tappas.org/contact</a> or send an email to <b>[email protected]</b> relative to tappAS installation or errors or to <b>[email protected]</b> for tappAS functionality.

</div>
</span>
Expand Down
9 changes: 9 additions & 0 deletions resources/webFiles.txt~
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
appOverview.html
css/web.css
scripts/ebook.js
scripts/maps.js
scripts/overview.js
scripts/scripts.js
scripts/slides.js
images/appLayout.png

254 changes: 118 additions & 136 deletions scripts/DFI.R
Original file line number Diff line number Diff line change
Expand Up @@ -580,146 +580,128 @@ if(len_zero & cont_err == cont){
lstProtein = strsplit(proteinFeatures, ",")
dfi_total_count=read.table(file.path(inFileCount), sep="\t", header=TRUE, stringsAsFactors = F)

cat("\n1111. DFI_matrix original")
cat(as.character(head(result_dfi)))
cat("\n")

saveRDS(result_dfi, file = "D:/Pedro/Trabajo/CIPF/tappAS/tappasWorkspace/Projects/Project.0655359829.tappas/Data/DFI/my_data.rds")

cat("\nBuilding P-Values tables...")
dfi_matrix = unique(result_dfi[,c("gene","qValue")])
dfi_matrix$Feature = sapply(dfi_matrix$gene, getFeatureName)
dfi_matrix$Gene = sapply(dfi_matrix$gene, getGeneName)
dfi_matrix$DFI = ifelse(as.numeric(levels(dfi_matrix$qValue))[dfi_matrix$qValue]<=sig, "DFI", "Not DFI")

cat("\n2222. DFI_matrix original")
cat(as.character(head(dfi_matrix)))
cat("\n")

dfi_results = data.frame()
for(feature in unique(dfi_matrix$Feature)){
newRow = data.frame(Feature=feature,
TotalCount=nrow(dfi_matrix[dfi_matrix$Feature==feature,]),
DFICount=nrow(dfi_matrix[dfi_matrix$Feature==feature & dfi_matrix$DFI == "DFI",]),
TotalAnnot=sum(dfi_total_count[dfi_total_count$Feature==feature,]$Total),
Level=ifelse(feature %in% lstTrans, "Transcript","Protein"),
Time="0")
dfi_results = rbind(dfi_results,newRow)
}

cat("\3333. DFI_Results primera tabla")
cat(as.character(dfi_results))
cat("\n")

dfi_results["Freq1"] = dfi_results[,"TotalCount"]/sum(dfi_results[,"TotalCount"])*100
dfi_results["Freq2"] = dfi_results[,"TotalAnnot"]/sum(dfi_results[,"TotalAnnot"])*100
dfi_results$Feature = as.character(dfi_results$Feature)
dfi_results = dfi_results[order(dfi_results$Feature, method = ),]

#########
# TEST1 #
#########

# feature level
result_utrmotif = NULL
for(x in unique(dfi_results$Feature)){
xDFI = dfi_results[dfi_results$Feature==x,]$DFICount
xANNOT = dfi_results[dfi_results$Feature==x,]$TotalAnnot-xDFI
allDFI = sum(dfi_results[dfi_results$Feature!=x,]$DFICount)
allANNOT = sum(dfi_results[dfi_results$Feature!=x, ]$TotalAnnot)-allDFI

tbDFI <- matrix(c(xDFI,xANNOT,allDFI,allANNOT),ncol=2,byrow=TRUE)
colnames(tbDFI) <- c("DFI","ANNOT-DFI")
rownames(tbDFI) <- c("X","ALL")
tbDFI <- as.table(tbDFI)

result_utrmotif = rbind(result_utrmotif, c(x,fisher.test(x = tbDFI, alternative="less")$p.value, as.character(tbDFI)))
}
result_utrmotif_df = data.frame(result_utrmotif, stringsAsFactors = F)
result_utrmotif_df$X2 = as.numeric(result_utrmotif_df$X2)
result_utrmotif_df$adj = p.adjust(result_utrmotif_df$X2, method = "hochberg")
result_utrmotif_df = result_utrmotif_df[order(result_utrmotif_df$X1),]
colnames(result_utrmotif_df) = c("Feature","P-Value","feat_DFI","all_DFI","feat_ANNOT-DFI","all_ANNOT-DFI", "Adj.P-Value")
result_utrmotif_df$`P-Value` = signif(result_utrmotif_df$`P-Value`, digits = 5)
result_utrmotif_df$`Adj.P-Value` = signif(result_utrmotif_df$`Adj.P-Value`, digits = 5)

cat("\4444. DFI_Results segunda tabla")
cat(as.character(result_utrmotif_df))
cat("\n")

##############
# SAVE TESTS #
##############

write.table(result_utrmotif_df, file = outputTestFeatures, quote = FALSE, col.names = TRUE, row.names = FALSE, sep = "\t")

#########
# TEST2 #
#########

# gene level
cat("\nWriting DFI Test2 file...\n")
cat("\nBuilding P-Values tables...")
dfi_matrix = unique(result_dfi[,c("gene","qValue")])
dfi_matrix$Feature = sapply(dfi_matrix$gene, getFeatureName)
dfi_matrix$Gene = sapply(dfi_matrix$gene, getGeneName)
dfi_matrix$DFI = ifelse(as.numeric(levels(dfi_matrix$qValue))[dfi_matrix$qValue]<=sig, "DFI", "Not DFI")

dfi_results = data.frame()
for(feature in unique(dfi_matrix$Feature)){
newRow = data.frame(Feature=feature,
TotalCount=nrow(dfi_matrix[dfi_matrix$Feature==feature,]),
DFICount=nrow(dfi_matrix[dfi_matrix$Feature==feature & dfi_matrix$DFI == "DFI",]),
TotalAnnot=sum(dfi_total_count[dfi_total_count$Feature==feature,]$Total),
Level=ifelse(feature %in% lstTrans, "Transcript","Protein"),
Time="0")
dfi_results = rbind(dfi_results,newRow)
}

res_genes = NULL
dfi_matrix_genes = unique(dfi_matrix[,c("Gene","Feature","DFI")])
for(gene in unique(dfi_matrix_genes$Gene)){
for(feature in unique(dfi_matrix_genes[dfi_matrix_genes$Gene == gene,]$Feature)){
submatrix = dfi_matrix_genes[dfi_matrix_genes$Gene == gene & dfi_matrix_genes$Feature == feature,]
if(nrow(submatrix)>1) #a DFI and Not DFI
res_genes = rbind(res_genes, submatrix[submatrix$DFI == "DFI",])
else
res_genes = rbind(res_genes, submatrix)
dfi_results["Freq1"] = dfi_results[,"TotalCount"]/sum(dfi_results[,"TotalCount"])*100
dfi_results["Freq2"] = dfi_results[,"TotalAnnot"]/sum(dfi_results[,"TotalAnnot"])*100
dfi_results$Feature = as.character(dfi_results$Feature)
dfi_results = dfi_results[order(dfi_results$Feature, method = ),]

#########
# TEST1 #
#########

# feature level
result_utrmotif = NULL
for(x in unique(dfi_results$Feature)){
xDFI = dfi_results[dfi_results$Feature==x,]$DFICount
xANNOT = dfi_results[dfi_results$Feature==x,]$TotalAnnot-xDFI
allDFI = sum(dfi_results[dfi_results$Feature!=x,]$DFICount)
allANNOT = sum(dfi_results[dfi_results$Feature!=x, ]$TotalAnnot)-allDFI

tbDFI <- matrix(c(xDFI,xANNOT,allDFI,allANNOT),ncol=2,byrow=TRUE)
colnames(tbDFI) <- c("DFI","ANNOT-DFI")
rownames(tbDFI) <- c("X","ALL")
tbDFI <- as.table(tbDFI)

result_utrmotif = rbind(result_utrmotif, c(x,fisher.test(x = tbDFI, alternative="less")$p.value, as.character(tbDFI)))
}
result_utrmotif_df = data.frame(result_utrmotif, stringsAsFactors = F)
result_utrmotif_df$X2 = as.numeric(result_utrmotif_df$X2)
result_utrmotif_df$adj = p.adjust(result_utrmotif_df$X2, method = "hochberg")
result_utrmotif_df = result_utrmotif_df[order(result_utrmotif_df$X1),]
colnames(result_utrmotif_df) = c("Feature","P-Value","feat_DFI","all_DFI","feat_ANNOT-DFI","all_ANNOT-DFI", "Adj.P-Value")
result_utrmotif_df$`P-Value` = signif(result_utrmotif_df$`P-Value`, digits = 5)
result_utrmotif_df$`Adj.P-Value` = signif(result_utrmotif_df$`Adj.P-Value`, digits = 5)

##############
# SAVE TESTS #
##############

write.table(result_utrmotif_df, file = outputTestFeatures, quote = FALSE, col.names = TRUE, row.names = FALSE, sep = "\t")

#########
# TEST2 #
#########

# gene level
cat("\nWriting DFI Test2 file...\n")

res_genes = NULL
dfi_matrix_genes = unique(dfi_matrix[,c("Gene","Feature","DFI")])
for(gene in unique(dfi_matrix_genes$Gene)){
for(feature in unique(dfi_matrix_genes[dfi_matrix_genes$Gene == gene,]$Feature)){
submatrix = dfi_matrix_genes[dfi_matrix_genes$Gene == gene & dfi_matrix_genes$Feature == feature,]
if(nrow(submatrix)>1) #a DFI and Not DFI
res_genes = rbind(res_genes, submatrix[submatrix$DFI == "DFI",])
else
res_genes = rbind(res_genes, submatrix)
}
}
}

dfi_results = data.frame()
for(feature in unique(res_genes$Feature)){
newRow = data.frame(Feature=feature,
TotalCount=nrow(res_genes[res_genes$Feature==feature,]),
DFICount=nrow(res_genes[res_genes$Feature==feature & res_genes$DFI == "DFI",]),
TotalAnnot=sum(dfi_total_count[dfi_total_count$Feature==feature,]$ByGenes),
Level=ifelse(feature %in% lstTrans, "Transcript","Protein"),
Time="0")
dfi_results = rbind(dfi_results,newRow)
}
dfi_results = data.frame()
for(feature in unique(res_genes$Feature)){
newRow = data.frame(Feature=feature,
TotalCount=nrow(res_genes[res_genes$Feature==feature,]),
DFICount=nrow(res_genes[res_genes$Feature==feature & res_genes$DFI == "DFI",]),
TotalAnnot=sum(dfi_total_count[dfi_total_count$Feature==feature,]$ByGenes),
Level=ifelse(feature %in% lstTrans, "Transcript","Protein"),
Time="0")
dfi_results = rbind(dfi_results,newRow)
}

dfi_results["Freq1"] = dfi_results[,"TotalCount"]/sum(dfi_results[,"TotalCount"])*100
dfi_results["Freq2"] = dfi_results[,"TotalAnnot"]/sum(dfi_results[,"TotalAnnot"])*100
dfi_results$Feature = as.character(dfi_results$Feature)
dfi_results = dfi_results[order(dfi_results$Feature, method = ),]

#########
# TEST2 #
#########

# gene level
result_utrmotif = NULL
for(x in unique(dfi_results$Feature)){
xDFI = dfi_results[dfi_results$Feature==x,]$DFICount
xANNOT = dfi_results[dfi_results$Feature==x,]$TotalAnnot-xDFI
allDFI = sum(dfi_results[dfi_results$Feature!=x,]$DFICount)
allANNOT = sum(dfi_results[dfi_results$Feature!=x, ]$TotalAnnot)-allDFI

tbDFI <- matrix(c(xDFI,xANNOT,allDFI,allANNOT),ncol=2,byrow=TRUE)
colnames(tbDFI) <- c("DFI","ANNOT-DFI")
rownames(tbDFI) <- c("X","ALL")
tbDFI <- as.table(tbDFI)

result_utrmotif = rbind(result_utrmotif, c(x,fisher.test(x = tbDFI, alternative="less")$p.value, as.character(tbDFI)))
}
result_utrmotif_gene = data.frame(result_utrmotif, stringsAsFactors = F)
result_utrmotif_gene$X2 = as.numeric(result_utrmotif_gene$X2)
result_utrmotif_gene$adj = p.adjust(result_utrmotif_gene$X2, method = "hochberg")
result_utrmotif_gene = result_utrmotif_gene[order(result_utrmotif_gene$X1),]
colnames(result_utrmotif_gene) = c("Feature","P-Value","feat_DFI","all_DFI","feat_ANNOT-DFI","all_ANNOT-DFI", "Adj.P-Value")
result_utrmotif_gene$`P-Value` = signif(result_utrmotif_gene$`P-Value`, digits = 5)
result_utrmotif_gene$`Adj.P-Value` = signif(result_utrmotif_gene$`Adj.P-Value`, digits = 5)

##############
# SAVE TESTS #
##############

write.table(result_utrmotif_gene, file = outputTestGenes, quote = FALSE, col.names = TRUE, row.names = FALSE, sep = "\t")
dfi_results["Freq1"] = dfi_results[,"TotalCount"]/sum(dfi_results[,"TotalCount"])*100
dfi_results["Freq2"] = dfi_results[,"TotalAnnot"]/sum(dfi_results[,"TotalAnnot"])*100
dfi_results$Feature = as.character(dfi_results$Feature)
dfi_results = dfi_results[order(dfi_results$Feature, method = ),]

#########
# TEST2 #
#########

# gene level
result_utrmotif = NULL
for(x in unique(dfi_results$Feature)){
xDFI = dfi_results[dfi_results$Feature==x,]$DFICount
xANNOT = dfi_results[dfi_results$Feature==x,]$TotalAnnot-xDFI
allDFI = sum(dfi_results[dfi_results$Feature!=x,]$DFICount)
allANNOT = sum(dfi_results[dfi_results$Feature!=x, ]$TotalAnnot)-allDFI

tbDFI <- matrix(c(xDFI,xANNOT,allDFI,allANNOT),ncol=2,byrow=TRUE)
colnames(tbDFI) <- c("DFI","ANNOT-DFI")
rownames(tbDFI) <- c("X","ALL")
tbDFI <- as.table(tbDFI)

result_utrmotif = rbind(result_utrmotif, c(x,fisher.test(x = tbDFI, alternative="less")$p.value, as.character(tbDFI)))
}
result_utrmotif_gene = data.frame(result_utrmotif, stringsAsFactors = F)
result_utrmotif_gene$X2 = as.numeric(result_utrmotif_gene$X2)
result_utrmotif_gene$adj = p.adjust(result_utrmotif_gene$X2, method = "hochberg")
result_utrmotif_gene = result_utrmotif_gene[order(result_utrmotif_gene$X1),]
colnames(result_utrmotif_gene) = c("Feature","P-Value","feat_DFI","all_DFI","feat_ANNOT-DFI","all_ANNOT-DFI", "Adj.P-Value")
result_utrmotif_gene$`P-Value` = signif(result_utrmotif_gene$`P-Value`, digits = 5)
result_utrmotif_gene$`Adj.P-Value` = signif(result_utrmotif_gene$`Adj.P-Value`, digits = 5)

##############
# SAVE TESTS #
##############

write.table(result_utrmotif_gene, file = outputTestGenes, quote = FALSE, col.names = TRUE, row.names = FALSE, sep = "\t")

cat("\nAll done.\n")
}
Loading

0 comments on commit 87d7749

Please sign in to comment.