From 595aed52c4ce90a09aa41b73563c182b01303a71 Mon Sep 17 00:00:00 2001 From: ubyndr Date: Tue, 16 Apr 2024 09:44:19 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20INCATool?= =?UTF-8?q?s/pandasaurus=5Fcxg@0a4765c4651339afb44889b34d38e326b00b8a63=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pandasaurus_cxg/anndata_analyzer.html | 4 +- .../pandasaurus_cxg/anndata_enricher.html | 10 ++-- .../graph_generator/graph_generator.html | 53 +++++++------------ 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/_modules/pandasaurus_cxg/anndata_analyzer.html b/_modules/pandasaurus_cxg/anndata_analyzer.html index d6522a2..4fe08db 100644 --- a/_modules/pandasaurus_cxg/anndata_analyzer.html +++ b/_modules/pandasaurus_cxg/anndata_analyzer.html @@ -259,7 +259,9 @@

Source code for pandasaurus_cxg.anndata_analyzer

enriched_df = enricher.enricher.enriched_df if enriched_df.empty: return enriched_df - return enriched_df[enriched_df["o"].isin(enricher.seed_list)][["s_label", "o_label"]] + return enriched_df[enriched_df["o"].isin(list(enricher.seed_dict.keys()))][ + ["s_label", "o_label"] + ] def _filter_data_and_drop_duplicates(self, field_name_1, field_name_2, disease): # Filter the data based on the disease condition diff --git a/_modules/pandasaurus_cxg/anndata_enricher.html b/_modules/pandasaurus_cxg/anndata_enricher.html index 7fec804..8642f68 100644 --- a/_modules/pandasaurus_cxg/anndata_enricher.html +++ b/_modules/pandasaurus_cxg/anndata_enricher.html @@ -121,8 +121,12 @@

Source code for pandasaurus_cxg.anndata_enricher

ontology_list_for_slims = ["Cell Ontology"] # TODO Do we need to keep whole anndata? Would it be enough to keep the obs only? self.anndata = anndata - self.seed_list = self.anndata.obs[cell_type_field].unique().tolist() - self.enricher = Query(self.seed_list) + self.seed_dict = dict( + self.anndata.obs.drop_duplicates(subset=[cell_type_field, "cell_type"])[ + [cell_type_field, "cell_type"] + ].values + ) + self.enricher = Query(list(self.seed_dict.keys())) try: unique_context = self.anndata.obs[ [context_field, context_field_label] @@ -324,7 +328,7 @@

Source code for pandasaurus_cxg.anndata_enricher

Args: property_list (List[str]): The list of properties to include in the enrichment analysis. """ - self.enricher = Query(self.seed_list, property_list)
+ self.enricher = Query(list(self.seed_dict.keys()), property_list)
diff --git a/_modules/pandasaurus_cxg/graph_generator/graph_generator.html b/_modules/pandasaurus_cxg/graph_generator/graph_generator.html index c3937be..51c9910 100644 --- a/_modules/pandasaurus_cxg/graph_generator/graph_generator.html +++ b/_modules/pandasaurus_cxg/graph_generator/graph_generator.html @@ -222,43 +222,13 @@

Source code for pandasaurus_cxg.graph_generator.graph_generator

self.graph.add((resource, subcluster, s)) # transitive reduction step - self.graph = graphgen.apply_transitive_reduction(self.graph, [subcluster.toPython()])
+ self.graph = graphgen.apply_transitive_reduction(self.graph, [subcluster.toPython()]) - -
-[docs] - def enrich_rdf_graph(self): - """ - Enrich RDF graph with enriched DataFrame from AnndataEnricher - - Returns: - - """ - if self.ea.enricher_manager.enricher.enriched_df.empty: - # TODO or we can just call simple_enrichment method - enrichment_methods = [i for i in dir(AnndataEnricher) if "_enrichment" in i] - enrichment_methods.sort() - raise MissingEnrichmentProcess(enrichment_methods) - cell_type_dict = ( - pd.concat( - [ - self.ea.enricher_manager.enricher.enriched_df[["s", "s_label"]], - self.ea.enricher_manager.enricher.enriched_df[["o", "o_label"]].rename( - columns={"o": "s", "o_label": "s_label"} - ), - ], - axis=0, - ignore_index=True, - ) - .drop_duplicates() - .set_index("s")["s_label"] - .to_dict() - ) # add cell_type nodes and consists_of relations cl_namespace = Namespace("http://purl.obolibrary.org/obo/CL_") consist_of = URIRef(CONSIST_OF.get("iri")) self.graph.add((consist_of, RDFS.label, Literal(CONSIST_OF.get("label")))) - for curie, label in cell_type_dict.items(): + for curie, label in self.ea.enricher_manager.seed_dict.items(): resource = cl_namespace[curie.split(":")[-1]] self.graph.add((resource, RDFS.label, Literal(label))) self.graph.add((resource, RDF.type, OWL.Class)) @@ -270,9 +240,24 @@

Source code for pandasaurus_cxg.graph_generator.graph_generator

self.graph.add((class_expression_bnode, OWL.onProperty, consist_of)) self.graph.add((class_expression_bnode, OWL.someValuesFrom, resource)) # Add the restriction - self.graph.add((s, RDF.type, class_expression_bnode)) + self.graph.add((s, RDF.type, class_expression_bnode))
+ + +
+[docs] + def enrich_rdf_graph(self): + """ + Enrich RDF graph with enriched DataFrame from AnndataEnricher - # add enrichment graph + Returns: + + """ + if self.ea.enricher_manager.enricher.enriched_df.empty: + # TODO or we can just call simple_enrichment method + enrichment_methods = [i for i in dir(AnndataEnricher) if "_enrichment" in i] + enrichment_methods.sort() + raise MissingEnrichmentProcess(enrichment_methods) + # add enrichment graph, subClassOf relations self.graph += self.ea.enricher_manager.enricher.graph