Beispiel #1
0
 public void Add_new_mbco_association_lines_after_filtering_for_bg_genes(MBCO_association_class new_mbco_association)
 {
     if (this.Bg_genes.Length > 0)
     {
         new_mbco_association.Keep_only_bg_symbols(this.Bg_genes);
     }
     this.MBCO_association.Add_array_of_other_MBCO_association(new_mbco_association);
 }
Beispiel #2
0
 public void Generate(MBCO_association_class mbco_association, Ontology_type_enum ontology, params string[] bg_symbols)
 {
     this.Ontology         = ontology;
     this.Bg_genes         = Array_class.Deep_copy_string_array(bg_symbols);
     this.MBCO_association = mbco_association.Deep_copy();
     if (this.Bg_genes.Length > 0)
     {
         MBCO_association.Keep_only_bg_symbols(bg_symbols);
     }
 }
Beispiel #3
0
 private void Generate_mbco_association(string[] bg_genes)
 {
     if (Options.Report)
     {
         Report_class.WriteLine("{0}: Generate MBCO gene-SCP association networks", typeof(Mbc_enrichment_pipeline_class).Name);
     }
     MBCO_association = new MBCO_association_class();
     MBCO_association.Generate_by_reading_safed_file();
     string[] all_mbco_genes = MBCO_association.Get_all_distinct_ordered_symbols();
     if (bg_genes.Length > 0)
     {
         this.Exp_bg_genes   = Array_class.Deep_copy_string_array(bg_genes);
         this.Final_bg_genes = Overlap_class.Get_intersection(this.Exp_bg_genes, all_mbco_genes);
     }
     else
     {
         this.Exp_bg_genes   = new string[0];
         this.Final_bg_genes = Array_class.Deep_copy_string_array(all_mbco_genes);
     }
     this.MBCO_association.Keep_only_bg_symbols(this.Final_bg_genes);
     this.MBCO_association.Remove_background_genes_scp();
     this.MBCO_fisher_standard = new Ontology_fisher_class();
     this.MBCO_fisher_standard.Generate(this.MBCO_association, Ontology_type_enum.Molecular_biology_cell, this.Final_bg_genes);
 }
Beispiel #4
0
        private Ontology_enrichment_class Do_dynamic_enrichment_analysis_for_mbco_and_write(Ontology_enrichment_class mbco_onto_enrich_standard, Data_class data)
        {
            if (Options.Report)
            {
                Report_class.WriteLine("{0}: Do dynamic enrichment analysis and write results", typeof(Mbc_enrichment_pipeline_class).Name);
            }
            string subdirectory = Get_results_subdirectory_for_indicated_ontology(Ontology_type_enum.Molecular_biology_cell);

            mbco_onto_enrich_standard.Order_by_complete_sample_pvalue();
            int mbco_onto_enrich_length = mbco_onto_enrich_standard.Enrich.Length;
            Ontology_enrichment_line_class enrich_line;

            MBCO_association_line_class[]         new_mbco_association_lines;
            MBCO_association_class                new_mbco_association;
            List <Ontology_enrichment_line_class> current_onto_enrich = new List <Ontology_enrichment_line_class>();
            Ontology_fisher_class mbco_fisher_dynamic;
            int        col_length = data.ColChar.Columns.Length;
            Data_class current_data;
            Colchar_column_line_class             current_column_line;
            Ontology_enrichment_class             current_dynamic_onto_enrich;
            Ontology_enrichment_class             complete_dynamic_onto_enrich = new Ontology_enrichment_class();
            List <Ontology_enrichment_line_class> dynamic_onto_enrich_list     = new List <Ontology_enrichment_line_class>();
            int added_standard_results_count = 0;

            for (int indexCol = 0; indexCol < col_length; indexCol++)
            {
                current_data = data.Deep_copy();
                current_data.Keep_only_input_columns_and_remove_all_rows_that_are_left_over_with_only_zero_values(indexCol);
                current_column_line = current_data.ColChar.Columns[0];
                current_onto_enrich.Clear();
                for (int indexMbco = 0; indexMbco < mbco_onto_enrich_length; indexMbco++)
                {
                    enrich_line = mbco_onto_enrich_standard.Enrich[indexMbco];
                    if ((enrich_line.EntryType.Equals(current_column_line.EntryType)) &&
                        (enrich_line.Timepoint.Equals(current_column_line.Timepoint)) &&
                        (enrich_line.Sample_name.Equals(current_column_line.SampleName)))
                    {
                        current_onto_enrich.Add(enrich_line);
                        added_standard_results_count++;
                    }
                }
                if (current_onto_enrich.Count == 0)
                {
                    throw new Exception();
                }
                new_mbco_association_lines = Generate_new_mbco_association_lines_by_merging_neighboring_scps(current_onto_enrich.ToArray());
                new_mbco_association       = new MBCO_association_class();
                new_mbco_association.Add_to_array(new_mbco_association_lines);
                mbco_fisher_dynamic = new Ontology_fisher_class();
                mbco_fisher_dynamic.Generate(new_mbco_association, Ontology_type_enum.Molecular_biology_cell, this.Final_bg_genes);
                current_dynamic_onto_enrich = mbco_fisher_dynamic.Analyse_data_instance(current_data);
                complete_dynamic_onto_enrich.Add_other(current_dynamic_onto_enrich);
            }
            if (added_standard_results_count != mbco_onto_enrich_standard.Enrich.Length)
            {
                throw new Exception();
            }

            complete_dynamic_onto_enrich.Add_other(mbco_onto_enrich_standard);
            complete_dynamic_onto_enrich.Keep_only_enrichment_lines_of_indicated_levels(Options.Scp_levels_for_dynamicEnrichment);
            complete_dynamic_onto_enrich.Write(subdirectory, "Dynamic_enrichment_results.txt");

            Ontology_enrichment_class complete_dynamic_onto_enrich_filtered = complete_dynamic_onto_enrich.Deep_copy();

            complete_dynamic_onto_enrich_filtered.Keep_enrichment_lines_below_pvalue_cutoff(Options.Maximum_pvalue_for_standardDynamicEnrichment);
            complete_dynamic_onto_enrich_filtered.Keep_top_x_predictions_per_level_for_each_sample(Options.Kept_top_predictions_dynamicEnrichment_per_level);
            complete_dynamic_onto_enrich_filtered.Keep_top_x_predictedSCPs_as_part_of_SCPunit_or_singleSCPs(Options.Kept_singleSCPs_dynamicEnrichment_per_level);
            complete_dynamic_onto_enrich_filtered.Write(subdirectory, "Dynamic_enrichment_results_filtered.txt");
            return(complete_dynamic_onto_enrich_filtered);
        }