2626# Ingest dense file
2727python ingest_pipeline.py --study-id 5d276a50421aa9117c982845 --study-file-id 5dd5ae25421aa910a723a337 ingest_expression --taxon-name 'Homo sapiens' --taxon-common-name human --ncbi-taxid 9606 --matrix-file ../tests/data/dense_matrix_19_genes_1000_cells.txt --matrix-file-type dense
2828
29- # Ingest h5ad file
30- python ingest_pipeline.py --study-id 5d276a50421aa9117c982845 --study-file-id 5dd5ae25421aa910a723a337 ingest_h5ad --h5ad -file ../tests/data/test.h5ad
29+ # Ingest AnnData file
30+ python ingest_pipeline.py --study-id 5d276a50421aa9117c982845 --study-file-id 5dd5ae25421aa910a723a337 ingest_anndata --anndata -file ../tests/data/anndata /test.h5ad
3131
3232# Subsample cluster and metadata file
3333python ingest_pipeline.py --study-id 5d276a50421aa9117c982845 --study-file-id 5dd5ae25421aa910a723a337 ingest_subsample --cluster-file ../tests/data/test_1k_cluster_Data.csv --name custer1 --cell-metadata-file ../tests/data/test_1k_metadata_Data.csv --subsample
5151from contextlib import nullcontext
5252from typing import Dict , Generator , List , Tuple , Union
5353from wsgiref .simple_server import WSGIRequestHandler # noqa: F401
54-
55-
5654from bson .objectid import ObjectId
5755
58-
59- # from google.cloud.logging.resource import Resource
6056try :
6157 # Used when importing internally and in tests
6258 from ingest_files import IngestFiles
8278 from clusters import Clusters
8379 from expression_files .mtx import MTXIngestor
8480 from expression_files .dense_ingestor import DenseIngestor
85- from h5ad import H5adIngestor
8681 from monitor import setup_logger , log_exception
8782 from de import DifferentialExpression
8883
84+ # scanpy uses anndata python package, disamibguate local anndata
85+ # using underscore https://peps.python.org/pep-0008/#naming-conventions
86+ from anndata_ import AnnDataIngestor
87+
8988except ImportError :
9089 # Used when importing as external package, e.g. imports in single_cell_portal code
9190 from .ingest_files import IngestFiles
103102 from .clusters import Clusters
104103 from .expression_files .dense_ingestor import DenseIngestor
105104 from .expression_files .mtx import MTXIngestor
106- from .h5ad import H5adIngestor
105+ from .anndata import AnnDataIngestor
107106 from .cli_parser import create_parser , validate_arguments
108107 from .de import DifferentialExpression
109108
@@ -127,7 +126,7 @@ def __init__(
127126 matrix_file_type : str = None ,
128127 cell_metadata_file : str = None ,
129128 cluster_file : str = None ,
130- h5ad_file : str = None ,
129+ anndata_file : str = None ,
131130 subsample = False ,
132131 ingest_cell_metadata = False ,
133132 ingest_cluster = False ,
@@ -147,7 +146,7 @@ def __init__(
147146 else :
148147 self .db = None
149148 self .cluster_file = cluster_file
150- self .h5ad_file = h5ad_file
149+ self .anndata_file = anndata_file
151150 self .kwargs = kwargs
152151 self .cell_metadata_file = cell_metadata_file
153152 self .props = {}
@@ -479,15 +478,15 @@ def subsample(self):
479478 return 0
480479
481480 @custom_metric (config .get_metric_properties )
482- def ingest_h5ad (self ):
483- """Ingests h5ad files."""
484- self .h5ad = H5adIngestor (
485- self .h5ad_file , self .study_id , self .study_file_id , ** self .kwargs
481+ def ingest_anndata (self ):
482+ """Ingests anndata files."""
483+ self .anndata = AnnDataIngestor (
484+ self .anndata_file , self .study_id , self .study_file_id , ** self .kwargs
486485 )
487- if self .h5ad .validate ():
486+ if self .anndata .validate ():
488487 self .report_validation ("success" )
489488 return 0
490- # scanpy unable to open h5ad file
489+ # scanpy unable to open AnnData file
491490 else :
492491 self .report_validation ("failure" )
493492 return 1
@@ -541,11 +540,11 @@ def run_ingest(ingest, arguments, parsed_args):
541540 config .set_parent_event_name ("ingest-pipeline:subsample:ingest" )
542541 status_subsample = ingest .subsample ()
543542 status .append (status_subsample )
544- elif "ingest_h5ad " in arguments :
545- if arguments ["ingest_h5ad " ]:
546- config .set_parent_event_name ("ingest-pipeline:h5ad :ingest" )
547- status_h5ad = ingest .ingest_h5ad ()
548- status .append (status_h5ad )
543+ elif "ingest_anndata " in arguments :
544+ if arguments ["ingest_anndata " ]:
545+ config .set_parent_event_name ("ingest-pipeline:anndata :ingest" )
546+ status_anndata = ingest .ingest_anndata ()
547+ status .append (status_anndata )
549548 elif "differential_expression" in arguments :
550549 config .set_parent_event_name ("ingest-pipeline:differential-expression" )
551550 status_de = ingest .calculate_de ()
0 commit comments