Plot GO DAGs for all groups of user GOs.
165015
def plot_groups_all(self, fout_dir=".", **kws_pltargs): # GrouperUserGos
        """"""
        hdrgos = self.grprobj.get_hdrgos()
        pltargs = PltGroupedGosArgs(self.grprobj, fout_dir=fout_dir, **kws_pltargs)
        return self._plot_groups_hdrgos(hdrgos, pltargs)
459339
def fill_main_goids(go2obj, goids):
    """"""
    # User GO IDs (goids) may be either main GO IDs or alternate GO IDs.
    for goid in goids:
        goobj = go2obj[goid]
        # If a user specified an ALT GO ID and main GO ID not in go2obj:
        if goid != goobj.id and goobj.id not in go2obj:
            # Add main GO ID to go2obj
            go2obj[goobj.id] = goobj
813936
def plotit(self):
        '''
        
        '''
        [self._plot(i) for i in range(len(self.plots))]
1188271
def generate_dags(self, globals: Dict[str, Any]) -> None:
        
        dag_configs: Dict[str, Dict[str, Any]] = self.get_dag_configs()
        default_config: Dict[str, Any] = self.get_default_config()

        for dag_name, dag_config in dag_configs.items():
            dag_builder: DagBuilder = DagBuilder(dag_name=dag_name,
                                                 dag_config=dag_config,
                                                 default_config=default_config)
            try:
                dag: Dict[str, Union[str, DAG]] = dag_builder.build()
            except Exception as e:
                raise Exception(
                    f"Failed to generate dag {dag_name}. make sure config is properly populated. err:{e}"
                )
            globals[dag["dag_id"]]: DAG = dag["dag"]
1041988
def _get_go2nt(self, goids):
        """"""
        go2nt_all = self.grprobj.go2nt
        return {go:go2nt_all[go] for go in goids}
78532
def plot_gos(fout_png, goids, obo_dag, *args, **kws):
    """"""
    engine = kws['engine'] if 'engine' in kws else 'pydot'
    godagsmall = OboToGoDagSmall(goids=goids, obodag=obo_dag).godag
    godagplot = GODagSmallPlot(godagsmall, *args, **kws)
    godagplot.plt(fout_png, engine)
1137904
def umap(adata, **kwargs) -> Union[Axes, List[Axes], None]:
    
    return plot_scatter(adata, 'umap', **kwargs)
946431
def wrplt(self, fout_dir, plt_ext="png"):
        """"""
        # Ex basename
        basename = self.grprobj.get_fout_base(self.ntplt.hdrgo)
        plt_pat = self.get_pltpat(plt_ext)
        fout_basename = plt_pat.format(BASE=basename)
        fout_plt = os.path.join(fout_dir, fout_basename)
        self.gosubdagplot.plt_dag(fout_plt) # Create Plot
        return fout_plt
316926
def run_cli():
    ""

    features_path, groups_path, weight_method, num_bins, edge_range, \
    trim_outliers, trim_percentile, return_networkx_graph, out_weights_path = parse_args()

    # TODO add the possibility to process multiple combinations of parameters: diff subjects, diff metrics
    # for features_path to be a file containing multiple subjects (one/line)
    # -w could take multiple values kldiv,histint,
    # each line: input_features_path,out_weights_path

    features, groups = read_features_and_groups(features_path, groups_path)

    extract(features, groups, weight_method=weight_method, num_bins=num_bins,
            edge_range=edge_range, trim_outliers=trim_outliers, trim_percentile=trim_percentile,
            return_networkx_graph=return_networkx_graph, out_weights_path=out_weights_path)
331582
def _plt_pydot(self, fout_img):
        """"""
        dag = self._get_pydot_graph()
        img_fmt = os.path.splitext(fout_img)[1][1:]
        dag.write(fout_img, format=img_fmt)
        self.log.write("  {GO_USR:>3} usr {GO_ALL:>3} GOs  WROTE: {F}\n".format(
            F=fout_img,
            GO_USR=len(self.godag.go_sources),
            GO_ALL=len(self.godag.go2obj)))
18056
def _rm_gos_edges(rm_goids, edges_all):
        """"""
        edges_reduced = []
        for goid_child, goid_parent in sorted(edges_all, key=lambda t: t[1]):
            if goid_child not in rm_goids and goid_parent not in rm_goids:
                edges_reduced.append((goid_child, goid_parent))
        return edges_reduced
34240
def _to_graph(self, contexts):
        """"""
        prev = None

        for context in contexts:
            if prev is None:
                prev = context
                continue

            yield prev[0], context[1], context[0]
            prev = context
688152
def plt_goea_results(fout_png, goea_results, *args, **kws):
    """"""
    engine = kws['engine'] if 'engine' in kws else 'pydot'
    godagsmall = OboToGoDagSmall(goea_results=goea_results).godag
    godagplot = GODagSmallPlot(godagsmall, *args, goea_results=goea_results, **kws)
    godagplot.plt(fout_png, engine)
869139
def get_usrgos(self, fin_goids, prt):
        """"""
        ret = self.get_goids(None, fin_goids, prt)
        # If there have been no GO IDs explicitly specified by the user
        if not ret:
            # If the GO-DAG is sufficiently small, print all GO IDs
            if self.max_gos is not None and len(self.go2obj) < self.max_gos:
                main_gos = set(o.id for go, o in self.go2obj.items() if go != o.id)
                go_leafs = set(go for go, o in self.go2obj.items() if not o.children)
                ret = go_leafs.difference(main_gos)
            else:
                raise RuntimeError("GO IDs NEEDED")
        go2obj = self.get_go2obj(ret)
        return get_go2obj_unique(go2obj)
590868
def prt_gos_grouped(self, prt, **kws_grp):
        """"""
        prtfmt = self.datobj.kws['fmtgo']
        wrobj = WrXlsxSortedGos(self.name, self.sortobj)
        # Keyword arguments: control content: hdrgo_prt section_prt top_n use_sections
        desc2nts = self.sortobj.get_desc2nts(**kws_grp)
        wrobj.prt_txt_desc2nts(prt, desc2nts, prtfmt)
25092
def plot_all(*args, **kwargs):
    '''
    
    '''
    dfs = do_all(*args, **kwargs)
    ps = []
    for line in dfs:
        f, df, config = line
        df.plot(title=config['name'])
        ps.append(df)
    return ps
497447
def dag(self) -> Tuple[Dict, Dict]:
        
        from pipelines import dags

        operation_runs = self.operation_runs.all().prefetch_related('downstream_runs')

        def get_downstream(op_run):
            return op_run.downstream_runs.values_list('id', flat=True)

        return dags.get_dag(operation_runs, get_downstream)