From 05157c7ef769aac370d4d87965f28441031f29a2 Mon Sep 17 00:00:00 2001 From: Elizabeth Kiernan <55763654+ekiernan@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:51:35 -0500 Subject: [PATCH] adding GTF to uns field of h5ad for optimus (#154) updated warp-tools to 2.6.0 for modified h5ad scripts that add gtf file path into h5ad unstructured metadata --- tools/scripts/create_h5ad_optimus.py | 13 +++++++++++++ .../scripts/create_snrna_optimus_exons_h5ad.py | 17 +++++++++++++++++ tools/scripts/create_snrna_optimus_full_h5ad.py | 16 ++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/tools/scripts/create_h5ad_optimus.py b/tools/scripts/create_h5ad_optimus.py index ec8bd12e..210f62a7 100755 --- a/tools/scripts/create_h5ad_optimus.py +++ b/tools/scripts/create_h5ad_optimus.py @@ -390,6 +390,11 @@ def create_h5ad_files(args): # Set variable names new_data.var_names = [x for x in new_data.var["Gene"]] + # Add GTF to uns field + + gtf_path = args.gtf_path + new_data.uns["reference_gtf_file"] = gtf_path + # Write h5ad file new_data.write(args.output_h5ad_path + ".h5ad") @@ -458,6 +463,14 @@ def main(): help="annotation file in GTF format", ) + parser.add_argument( + "--gtf_path", + dest="gtf_path", + default=None, + required=False, + help="annotation file path", + ) + parser.add_argument( "--output_path_for_h5ad", dest="output_h5ad_path", diff --git a/tools/scripts/create_snrna_optimus_exons_h5ad.py b/tools/scripts/create_snrna_optimus_exons_h5ad.py index 3250ee3a..d1876e61 100644 --- a/tools/scripts/create_snrna_optimus_exons_h5ad.py +++ b/tools/scripts/create_snrna_optimus_exons_h5ad.py @@ -352,6 +352,15 @@ def create_h5ad_files(args): # Set the layer = to the exon_counts csr matrix new_data.layers["exon_counts"]=exon_counts + # Original path from args.annotation_file + # Add GTF to uns field + + gtf_path = args.gtf_path + new_data.uns["reference_gtf_file"] = gtf_path + + # Write h5ad file + new_data.write(args.output_h5ad_path + ".h5ad") + # Write h5ad file new_data.write(args.output_h5ad_path + ".h5ad") @@ -426,6 +435,14 @@ def main(): help="annotation file in GTF format", ) + parser.add_argument( + "--gtf_path", + dest="gtf_path", + default=None, + required=False, + help="annotation file path", + ) + parser.add_argument( "--output_path_for_h5ad", dest="output_h5ad_path", diff --git a/tools/scripts/create_snrna_optimus_full_h5ad.py b/tools/scripts/create_snrna_optimus_full_h5ad.py index d587c1f8..e74e513f 100755 --- a/tools/scripts/create_snrna_optimus_full_h5ad.py +++ b/tools/scripts/create_snrna_optimus_full_h5ad.py @@ -335,6 +335,14 @@ def create_h5ad_files(args): # Set variable names new_data.var_names = [x for x in new_data.var["Gene"]] + # Add GTF to uns field + + gtf_path = args.gtf_path + new_data.uns["reference_gtf_file"] = gtf_path + + # Write h5ad file + new_data.write(args.output_h5ad_path + ".h5ad") + # Write h5ad file new_data.write(args.output_h5ad_path + ".h5ad") @@ -390,6 +398,14 @@ def main(): help="annotation file in GTF format", ) + parser.add_argument( + "--gtf_path", + dest="gtf_path", + default=None, + required=False, + help="annotation file path", + ) + parser.add_argument( "--output_path_for_h5ad", dest="output_h5ad_path",