Mercurial > repos > goeckslab > scimap_spatial
diff scimap_phenotyping.py @ 2:d19c068c2490 draft
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit 9fb5578191db8a559191e45156cfb95350f01aea
author | goeckslab |
---|---|
date | Mon, 10 Jun 2024 18:44:35 +0000 |
parents | 42e6c251bfd0 |
children |
line wrap: on
line diff
--- a/scimap_phenotyping.py Mon Aug 29 23:55:43 2022 +0000 +++ b/scimap_phenotyping.py Mon Jun 10 18:44:35 2024 +0000 @@ -9,11 +9,12 @@ def main( adata, output, + log, gating_workflow, gating_workflow_ext, manual_gates=None, manual_gates_ext=None, - rescale_plots=False + random_state=0 ): """ Parameter @@ -22,6 +23,8 @@ File path to the input AnnData. output : str File path to the output AnnData. + log: bool + Boolean whether to log the input data prior to rescaling gating_workflow : str File path to the gating workflow. gating_workflow_ext : str @@ -30,8 +33,8 @@ File path to the munual gating. manual_gates_ext : str Datatype for munual gate, either 'csv' or 'tabular'. - rescale_plots : boolean - Save plots from rescaling. + random_state: int + The seed used by the random number generator for GMM in sm.pp.rescale """ warnings.simplefilter('ignore') @@ -41,13 +44,22 @@ sep = ',' if manual_gates_ext == 'csv' else '\t' manual_gates = pd.read_csv(manual_gates, sep=sep) - adata = sm.pp.rescale(adata, gate=manual_gates, save_fig=rescale_plots) + adata = sm.pp.rescale( + adata, + gate=manual_gates, + log=log, + random_state=random_state + ) # Phenotype cells # Load the gating workflow sep = ',' if gating_workflow_ext == 'csv' else '\t' phenotype = pd.read_csv(gating_workflow, sep=sep) - adata = sm.tl.phenotype_cells(adata, phenotype=phenotype, label="phenotype") + adata = sm.tl.phenotype_cells( + adata, + phenotype=phenotype, + label="phenotype" + ) # Summary of the phenotyping print(adata.obs['phenotype'].value_counts()) @@ -59,15 +71,50 @@ aparser = argparse.ArgumentParser() aparser.add_argument("-a", "--adata", dest="adata", required=True) aparser.add_argument("-o", "--output", dest="output", required=True) - aparser.add_argument("-g", "--gating_workflow", dest="gating_workflow", required=True) - aparser.add_argument("-s", "--gating_workflow_ext", dest="gating_workflow_ext", required=True) - aparser.add_argument("-m", "--manual_gates", dest="manual_gates", required=False) - aparser.add_argument("-S", "--manual_gates_ext", dest="manual_gates_ext", required=False) - aparser.add_argument("-p", "--rescale_plots", dest="rescale_plots", action="store_true", - default=False, required=False) + aparser.add_argument("-l", "--log", dest="log", action="store_true") + aparser.add_argument( + "-g", + "--gating_workflow", + dest="gating_workflow", + required=True + ) + aparser.add_argument( + "-s", + "--gating_workflow_ext", + dest="gating_workflow_ext", + required=True + ) + aparser.add_argument( + "-m", + "--manual_gates", + dest="manual_gates", + required=False + ) + aparser.add_argument( + "-S", + "--manual_gates_ext", + dest="manual_gates_ext", + required=False + ) + aparser.add_argument( + "--random_state", + dest="random_state", + type=int, + required=False + ) args = aparser.parse_args() - main(args.adata, args.output, args.gating_workflow, - args.gating_workflow_ext, args.manual_gates, - args.manual_gates_ext, args.rescale_plots) + if args.log: + print("\n adata.raw.X will be log1p transformed \n") + + main( + adata=args.adata, + output=args.output, + log=args.log, + gating_workflow=args.gating_workflow, + gating_workflow_ext=args.gating_workflow_ext, + manual_gates=args.manual_gates, + manual_gates_ext=args.manual_gates_ext, + random_state=args.random_state + )