Example #1
0
        public Ontology_enrichment_class Do_fisher_exact_test_for_de_instance_filter_and_write_for_individual_ontology(Deg_class deg)
        {
            int ontologies_length = this.Ontology_fishers.Length;
            Ontology_fisher_exact_class fisher;
            Ontology_enrichment_class   onto_enrich = new Ontology_enrichment_class();
            Ontology_enrichment_class   onto_enrich_add;

            for (int indexO = 0; indexO < ontologies_length; indexO++)
            {
                fisher          = this.Ontology_fishers[indexO];
                onto_enrich_add = fisher.Calculate_p_values_and_do_multiple_hypothesis_correction(deg);
                onto_enrich.Add_other(onto_enrich_add);
            }
            return(onto_enrich);
        }
Example #2
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);
        }