PICASO.kgraph
Classes
_summary_ Interface class for any network scoring class. |
|
_summary_ Interface class for any network scoring class. |
|
dict() -> new empty dictionary |
|
Functions
|
Module Contents
- class PICASO.kgraph.MidpointNormalize(vmin=None, vmax=None, midpoint=None, clip=False)
Bases:
matplotlib.colors.Normalize- midpoint
- __call__(value, clip=None)
- PICASO.kgraph.sjoined(inlist)
- class PICASO.kgraph.KGraph(random_state=42, kgraph_name='KGraph')
- kg
- random_state
- kgraph_name
- logger
- is_score_field(x)
- get_node_attributes()
- get_edge_attributes()
- __repr__()
- copy(suffix=None)
- print_kg_info()
- load_kgraph_base(data_dir, go=True, TFs=True, omnipath=True, opentargets=True, reactome=True, kegg=True, uniprot_loc=True, STRING=True, NPINTER=False, ot_min_disease_assoc_score=0.8, hallmark_genesets='kegg_gmts/human/c1.all.v2023.2.Hs.symbols.gmt', curated_genesets='kegg_gmts/human/c2.all.v2023.2.Hs.symbols.gmt')
- load_kgraph(infile)
- save_kgraph(outfile)
- get_node_data(node)
- get_node_edges(node, src_types=None, tgt_types=None)
- get_nodes(nodetype=None)
- get_nodes_with_highest_scores(n=3000, nodetype=None, score_accessor=lambda x: ..., node_filter=None)
- get_edges_with_highest_scores(n=3000, src_types=None, tgt_types=None, score_accessor=lambda x: ...)
- node_types(node, single=False)
- get_node_types(single=False)
- plot_node_types(show_threshold=0.02)
- plot_node_children(node_types=None)
- plot_child_distribution(plot=True)
- plot_edge_types(field='type', show_threshold=0.02)
- plot_edge_between_types(show_threshold=0.02)
- _plot_pie(counteritems, show_threshold=0.02)
- get_edge_types(field='type')
- get_edge_node_types(edge, field='type')
- get_edge_edge_types(src_types=None, tgt_types=None, type_accessor='type', ignore_edge_types=None)
- get_edge_between_type()
- add_gene_expression(exprDF, mean_column='mean', sd_column='sd', perc_expr_column='perc_expr', median_column='median', num_column='num', allnum_column='group_cells')
- get_node_type(node)
- get_edges_to_type(node, otype)
- get_edges_between_ntypes(src_types, tgt_types)
- _get_predecessors(start_node, ntype, n=10)
- score_nodes_hierarchically(ntype='geneset', target_ntype='gene', relevance_threshold=0, child_score_accessor=lambda x: ...)
- node_type_overlap(node, types)
- get_node_scores(score_accessor=lambda x: ..., nodes=None)
- get_edge_scores(score_accessor=lambda x: ..., edge_types=None, nodes=None)
- get_edge_scores_per_type(score_accessor=lambda x: ..., edge_types=None, single=False)
- plot_score_histogram(edge_types=None, score_accessor=lambda x: ...)
- plot_edge_attribute_distribution(edge_types=None, score_accessor=lambda x: ..., ax=None, title=None)
- plot_node_attribute_distribution(attribute_accessor, node_types=None, ax=None, title=None)
- plot_node_attribute_histogram(attribute_accessor, nodes=None, node_type=None, ax=None, title=None)
- plot_score_violin(per_edge_type=False, single_edge_types=False, edge_types=None, score_accessor=lambda x: ..., figsize=None)
- plot_subgraph_scores(scores)
- filter_nodes(filter_function)
- filter_edges(filter_function)
- subset_kg(retainedNodes, suffix='subset')
- induce_kg(retainedNodes, suffix='subset', radius=1)
- to_gene_kgraph()
- _filter_edge_score(score_field, minEdgeScore=3.0, undirected=True)
- get_communities_connectedcomponent(minEdgeScore=3.0, resolution=5, prefix='Community', sep='_', score_field='score')
- get_communities_greedymodularity(minEdgeScore=3.0, resolution=0.5, prefix='Community', sep='_', score_field='score')
- get_communities_asyn_label_propagation(minEdgeScore=3.0, prefix='Community', sep='_', score_field='score', seed=None)
- get_communities(minEdgeScore=3.0, resolution=5, prefix='Community', sep='_', score_field='score')
- get_communities_ecg(minEdgeScore=3.0, resolution=5, ens_size=16, prefix='Community', sep='_', score_field='score')
- get_communities_negpos(max_comm_size=50, prefix='Community', sep='_', score_field='score')
- get_communities_infomap(prefix='Community', sep=',')
Partition network with the Infomap algorithm. Annotates nodes with ‘community’ id and return number of communities found.
- get_communities_markovclustering(prefix='cluster', inflation=1.4)
- get_communities_link(minEdgeScore=3.0, threshold=0.15, score_field='score', prefix='Community', sep='_')
- describe_communities(comms)
- get_kg_subgraph(genes)
- plot_graph_network(outfile=None, notebook=False)
- get_nx_subgraph(genes)
- plot_graph(ax=None, figsize=(6, 6), title='', pos=None, close=True, font_size=8, edge_score_normalizer=None, node_score_normalizer=None, edge_cmap=plt.cm.Reds, max_node_size=200, nodetype2color={'gene': '#239756', 'geneset': '#3fc37e', 'disease': '#5047ee', 'drug': '#3026c1', 'NA': '#f37855'}, nodecolors={'gene': '#239756', 'geneset': '#3fc37e', 'disease': '#5047ee', 'drug': '#e600e6', 'NA': '#f37855'}, nodeshapes={'gene': 'o', 'geneset': 's', 'disease': '^', 'drug': 'p', 'NA': 'o'}, edge_score_accessor=lambda x: ..., node_score_accessor=lambda x: ..., legend=True)
- get_node_degrees(intype, connecttype=None)
- class PICASO.kgraph.NetworkScorer(random_state=42)
_summary_ Interface class for any network scoring class.
Hint: All scores must have their minimum at 0 ! This is required such that differential KGs can be successfully generated!
- random_state
- logger
- score()
- class PICASO.kgraph.MeanNetworkScorer(random_state=42)
Bases:
NetworkScorer_summary_ Interface class for any network scoring class.
Hint: All scores must have their minimum at 0 ! This is required such that differential KGs can be successfully generated!
- scoring_gene_gene_expression
- scoring_interactions
- score_edges(kgraph, value_accessor, edge_accessor, scorers, src_types=None, tgt_types=None, ignore_edge_types=None)
- score_nodes_from_properties(kgraph, ntypes=['measured_expression'], scoring_function=lambda x: ..., property_accessor=lambda x: ...)
- score_nodes_from_edges(kgraph, ntype='geneset', consider_edge_type=[('gene', 'geneset')], scoring_function=None, overwrite_score=False)
- score_nx(kg: networkx.DiGraph)
- calculate_edge_zscores(kgraph, score_accessor, edge_accessor, src_types=None, tgt_types=None, ignore_edge_types=None)
- class PICASO.kgraph.NetworkExtender
- extend_network(nodes, fullKG: KGraph, radius=1, scorer: NetworkScorer = None, min_children_gs=2, max_size_gs=100, minFraction_small=0.4, minFraction_large=0.5, node_types=['geneset', 'disease', 'ncRNA'], minGeneSpec={'geneset': 0.8, 'disease': 0.6}, min_edge_score=1.0, score_field='score', verbose=False)
- class PICASO.kgraph.CommunityTool
- scatter_community_scores(module_detail)
- visualize_communities(details, title, subsetOrderFunc=None, field='median', show_values=True)
- sort_communities(comm_details, details=False)
- plot_community(KGs, communityNodes, own, main_net=None, num_columns=4, title=None, nodecolors={'gene': '#239756', 'geneset': '#3fc37e', 'disease': '#5047ee', 'drug': '#3026c1', 'NA': '#f37855'}, outfile=None, dpi=500, show=True, edge_score_accessor=lambda x: ..., node_score_accessor=lambda x: ..., verbose=False)
- compare_modules(comms, figsize=(16, 12))
- class PICASO.kgraph.DifferentialCommunityIdentifier
- classmethod cohend(d1, d2)
- calculate_scores(allKGs, ref_kg, nodes, score_field)
- identify_differential_communities(communities, ref_kg, KGs, sort_function=None, score_field='score', use_statistic='cohend', min_nodes=10, min_enriched=0.5, min_effect_size=0.2, all_verbose=False, verbose=False)
- score_subgraphs_for_subnet(KGs, subnet, score_field='score')
- score_subgraphs(Gs, score_field='score', default_score=0)
- class PICASO.kgraph.GenesetAnnotator
- class PICASO.kgraph.DifferentialKG(pseudocount=0.01)
- pseudocount
- _get_log_foldchange(node1Score, node2Score, log2=True)
- calculate_diffkg_list(exprKGs, base_case, cases)
- class PICASO.kgraph.NETSIM(kg: KGraph, conf_score_accessor=lambda x: ...)
- kg
- orig_kg
- conf_score_accessor
- kg_rev
- undirected_x
- max_go_level = 10
- precalculated_term_genes
- get_annotated_genes(ta)
- confidence(gi, gj)
- dij(gi, gj)
- functional_distance_genesets(ta, tb, ga, gb)
- get_lca(ta, tb)
- get_shortest_path(ta, tb)
- get_path_constrained_annotation(ta, tb, p, verbose=False)
- get_node_name(node)
- functional_similarity(ta, tb, verbose=False)
- get_go_level(ta)
- lca_similarity(ta, tb, verbose=False)
- get_relevant_goterms(groupKG, max_terms=None, verbose=False)
- compare_modules_lca(skg1, skg2, max_terms=None, verbose=True)
- compare_modules(skg1, skg2, max_terms=None, verbose=True)
- class PICASO.kgraph.ModuleCompare
- classmethod makeProgressBar() progressbar.ProgressBar
- draw_network(G, title=None, borderWeightQuantile=0.8)
- module_similarities_to_df(modSims)
- network_compare_modules(inKGs, measure='jaccard', borderWeightQuantile=0.8)
- network_compare_lca(inKGs, max_terms=None, fullKG=None, ns=None, borderWeightQuantile=0.8)
- network_compare_netsim(inKGs, borderWeightQuantile=0.8, max_terms=None, fullKG=None, ns=None)
- plot_dendrogram(simDict, figsize=(8, 6), color_threshold=1)
- class PICASO.kgraph.CRankExplorer
-
- evaluate_communities(sigKGs, fullKGs, mod_sep='_mod_')
- plot_scores(scoreDF)
- class PICASO.kgraph.DefaultDict
Bases:
dictdict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- __missing__(key)
- class PICASO.kgraph.TwoLevelDifferentialAnalysis(tlDict, sorted_zones, output_folder_formatter, fullKG=None)
- tldict
- sorted_zones
- name_sep = '_mod_'
- cellgroupdata
- output_folder_formatter
- recalc_warning = False
- calculate_modules(relevant_cellgroups=None, cg_zone_formatter='{}_{}', reference_formatter='{}_Ref', diffkg=DifferentialKG(), overwrite=False)
- _get_diff_comms(tkgs, min_effect_size=1.0, resolution=4, minEdgeScore=1, min_node_scores={'drug': 1.0, 'ncRNA': 0.7}, network_extend_spec={'geneset': {'min_gene_spec': 0.5, 'max_size_gs': 200, 'min_fraction_large': 0.6, 'min_fraction_small': 0.5}, 'disease': {'min_gene_spec': 0.8, 'max_size_gs': 100, 'min_fraction_large': 0.7, 'min_fraction_small': 0.6}})
- plot_module_comparisons(plot_communities=False, ct=CommunityTool())
- _geneset_filter(n, kg)
- _filter_empty_genesets(n, kg)
- _filter_singletons(n, kg)
- _combined_filter(n, kg)
- property communities
- get_community(cid)
- get_community_details(cid)
- get_community_kg(cid)
- get_community_representation(cid, key='communities')
- plot_module_description(nrow=4, figsize=(10, 10), dcolors=None)
- _describe_kg(kg, name)
- describe_modules(relevant_cellgroups=None, non_verbose=False)
- create_overlap_df(nodetype)
- _calculate_gs_overlap(gsType, gsDict, moduleKG)
- _toShortName(x)
- describe_module_scrna(adata, sc_celltype_column, sc_condition_column, show_plot=True, plot_folder=None, plot_prefix='overview_plot_{}', module_names=None, gsTypes=['disease', 'geneset', 'drug'], numGenesThreshold=3, numElemsBarPlot=10, hue_colors={'gene': '#239756', 'geneset': '#3fc37e', 'disease': '#5047ee', 'drug': '#e600e6', 'NA': '#f37855'})
- available_cellgroups()
- class PICASO.kgraph.AIDescriptor(model_name='LoneStriker/BioMistral-7B-DARE-GGUF', model_file='BioMistral-7B-DARE-Q4_K_M.gguf', local_dir='../llm_addon/model/')
- model_name
- model_file
- local_dir
- model_path
- llm
- query_genelist(gene_list, context=None, verbose=False, word_cloud=False)
- _plot_wordcloud(text)
- query_wordcloud(gene_list, context)