view anndata_to_csv.py @ 2:302ddf03402f draft default tip

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/scimap commit c39cea5ae2ebf61b3d51d687fd9d2930c907b72d
author goeckslab
date Tue, 30 Jul 2024 18:21:02 +0000
parents 199b5f278356
children
line wrap: on
line source

import argparse
import json
import warnings

import scimap as sm
from anndata import read_h5ad


def main(inputs, outfile):
    """
    Parameters
    ---------
    inputs : str
        File path to galaxy tool parameter.
    anndata : str
        File path to anndata.
    output : str
        File path to output.
    """
    warnings.simplefilter('ignore')

    with open(inputs, 'r') as param_handler:
        params = json.load(param_handler)

    adata = read_h5ad(params['anndata'])

    if params['layer'] == 'x':
        params['layer'] = None

    df = sm.hl.scimap_to_csv(
        adata=adata,
        layer=params['layer'],
        CellID=params['cellid'],
    )

    df.to_csv(outfile, index=False)


if __name__ == '__main__':
    aparser = argparse.ArgumentParser()
    aparser.add_argument("-i", "--inputs", dest="inputs", required=True)
    aparser.add_argument("-e", "--outfile", dest="outfile", required=True)
    args = aparser.parse_args()

    main(args.inputs, args.outfile)