enrichr_working_dir <- "3_EnrichR"
r if(enrichr_section&length(g$gene_data_index)>0){"### EnrichR"}
g = g.enrichr(g)
r if(enrichr_section&length(g$gene_data_index)>0){paste("For EnrichR results, see ", g$enrichr_working_dir, " directory. ", sep="")}
enrichment_map <- gsea_section; # only run enrichment map if interactive session output_network_file <- FALSE; if(length(g$gene_data_index)>0 && (gsea_section || gsea_MOMENTA_section)){ g = g.gsea.prep(g) }
r if( gsea_section & species!="Other" & length(g$gene_data_index)>0){"### GSEA and EnrichmentMap"}
## This sections is based on the Bader Lab Enrichment Map Workflow. ## The connection between R and cytoscape must be configured for the last section. ## For more info: baderlab.github.io/Cytoscape_workflows/EnrichmentMapPipeline/ run_gsea <- gsea_section; # if GSEA has already been run, set to false and include results in directory if( run_gsea & species!="Other" ) { g = g.gsea(g) } # if(enrichment_map & species!="Other" ){ # gsea_output_paths <- rev(row.names(details)[1:length(analysis_names)]) # # try({ # # Basic settings # port.number = 1234 # base.url = paste("http://localhost:", toString(port.number), "/v1", sep="") # #print(base.url) # version.url = paste(base.url, "version", sep="/") # cytoscape.open = TRUE # tryCatch(expr = { GET(version.url)}, # error = function(e) { return (cytoscape.open = FALSE)}, # finally =function(r){ return(cytoscape.open = TRUE)}) # # if(!cytoscape.open){ # #try and launch cytoscape # print("Cytoscape is not open. Please launch cytoscape.") # } else{ # cytoscape.version = GET(version.url) # cy.version = fromJSON(rawToChar(cytoscape.version$content)) # print(cy.version) # } # # #defined threshold for GSEA enrichments (need to be strings for cyrest call) # pvalue_gsea_threshold <- enrichmentmap_p_val # qvalue_gsea_threshold <- enrichmentmap_q_val # similarity_threshold <- "0.375" # similarity_metric = "COMBINED" # # cur_model_name <- analysis_names[1] # current_network_name <- paste(cur_model_name,pvalue_gsea_threshold,qvalue_gsea_threshold,sep="_") # # gsea_results_paths <- paste(gsea_output_paths,"edb",sep="/") # gsea_results_filenames <- paste(gsea_results_paths,"results.edb",sep="/") # # # Although there is a gmt file in the gsea edb results directory it have been filtered to contain only genes represented in the expression set. # # If you use this fltered file you will get different pathway connectivity depending on the dataset being used. # # We recommend using original gmt file used for the gsea analysis and not the filtered one in the results directory. # gmt_gsea_file <- paste(dest_gmt_file,sep="/") # # em_command = paste('enrichmentmap build analysisType="gsea" gmtFile=',gmt_gsea_file, # 'pvalue=',pvalue_gsea_threshold, 'qvalue=',qvalue_gsea_threshold, # 'similaritycutoff=',similarity_threshold, # 'coefficients=',similarity_metric, # 'ranksDataset1=',rnk_files[[1]], # 'enrichmentsDataset1=',gsea_results_filenames[1], 'filterByExpressions=false', # 'expressionDataset1=',file.path(working_dir,expression_files[[1]]), # sep=" ") # # #enrichment map command will return the suid of newly created network. # try({ response <- commandsGET(em_command) }, silent=TRUE); # # current_network_suid <- 0 # #enrichment map command will return the suid of newly created network unless it Failed. If it failed it will contain the word failed # tryCatch({ # if(length(response)>0){ #fix for not getting suid # if(grepl(pattern="Failed", response)){ # paste(response) # } else { # current_network_suid <- response # response <- renameNetwork(new.name = current_network_name, network = current_network_suid, base.url) # # output_network_file <- paste(gsea_working_path,"screenshot_network.pdf",sep="/") # em_command2 = paste("view export OutputFile= ",output_network_file, " options=PDF", sep="") # commandsRun(em_command2) # em_command2 = paste("session save as file= ",paste(output_path,curr_model_name,sep="/"), sep="") # commandsRun(em_command2) # } # } # }, error=function(e){output_network_file=FALSE}) # # }, silent=TRUE) # }
r if(gsea_section & species!="Other" & length(g$gene_data_index)>0 ){paste("For GSEA results, see ", g$gsea_working_dir, " directory. ", sep="")}
r if(enrichment_map ){if( class(output_network_file)!="logical"){ "Click to view EnrichmentMap screen shot: \n"} }
r if(enrichment_map ){if( class(output_network_file)!="logical"){ paste(" | [ EnrichmentMap Image](",g$output_subdir,"/",gsea_working_dir,"/screenshot_network.pdf)", sep="") } }
r if(enrichment_map ){if( class(output_network_file)!="logical"){ "If multiple contrasts, load GSEA results into Cytoscape/EnrichmentMap manually."} }
if(dir.exists("Gene_Sets") | dir.exists(file.path("..","Gene_Sets")) ){ g = g.gsea.custom(g,run.GSEA=T) }
run_ksea <- length(g$phos_data_index)>0 & grepl("Human", species) & runDifferential;
r if( run_ksea ){"### Kinase Enrichment"}
g = g.ksea(g)
r if(run_ksea){"Click below to view KSEA results: "}
r if( run_ksea ){ g$ksea_output_links }
r if(run_ksea){paste("For complete KSEA results, see KSEA directory. ", sep="")}
show_metab_enrich <- ( grepl(paste("Human", "Mouse", "Fruit Fly", "Yeast", "E. coli", sep="|"),species) & gsea_MOMENTA_section )
r if( (show_metab_enrich& length(g$gene_data_index)>0 & runDifferential) ){"### GSEA for Metabolomic Models (MOMENTA)"}
if( gsea_MOMENTA_section & species!="Other" ) { g = g.gsea.momenta(g) }
r if( (show_metab_enrich& length(g$gene_data_index)>0 & runDifferential) ){paste("For complete GSEA-MOMENTA results, see ", g$gsea_working_dir ," directory. ", sep="")}
r if( length(g$metab_data_index)>0 ){"### Metabolite Enrichment"}
r if( length(g$metab_data_index)>0 ){"While perhaps the leading tool for metabolite pathway enrichment, the MetaboAnalyst R Package is still in development and work in progress. A recent update creates an error where the metabolic models are not available for download. If this is still the case when your analysis is run, you will see error messages below and no result files created for the metabolite enrichment analysis. In order to complete your analysis, you can take the files that beging with 'DE_matrix_' in the /Differential/files/ directory to upload to the MetaboAnalyst website (additional formatting may be required)."}
g = g.metabo.enrich(g)
r if(( length(g$metab_data_index)>0 ) ){paste("For complete results, see ", g$mumm_working_dir ," directory. ", sep="")}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.