@@ -445,6 +445,7 @@ def gene_cnv_frequencies_advanced(
445445 ci_method : Optional [frq_params .ci_method ] = frq_params .ci_method_default ,
446446 chunks : base_params .chunks = base_params .native_chunks ,
447447 inline_array : base_params .inline_array = base_params .inline_array_default ,
448+ taxon_by : frq_params .taxon_by = frq_params .taxon_by_default ,
448449 ) -> xr .Dataset :
449450 regions : List [Region ] = parse_multi_region (self , region )
450451 del region
@@ -466,6 +467,7 @@ def gene_cnv_frequencies_advanced(
466467 ci_method = ci_method ,
467468 chunks = chunks ,
468469 inline_array = inline_array ,
470+ taxon_by = taxon_by ,
469471 )
470472 for r in regions
471473 ],
@@ -494,6 +496,7 @@ def _gene_cnv_frequencies_advanced(
494496 ci_method ,
495497 chunks ,
496498 inline_array ,
499+ taxon_by ,
497500 ):
498501 debug = self ._log .debug
499502
@@ -523,6 +526,7 @@ def _gene_cnv_frequencies_advanced(
523526 df_samples = df_samples ,
524527 area_by = area_by ,
525528 period_by = period_by ,
529+ taxon_by = taxon_by ,
526530 )
527531
528532 debug ("group samples to make cohorts" )
@@ -532,6 +536,7 @@ def _gene_cnv_frequencies_advanced(
532536 df_cohorts = build_cohorts_from_sample_grouping (
533537 group_samples_by_cohort = group_samples_by_cohort ,
534538 min_cohort_size = min_cohort_size ,
539+ taxon_by = taxon_by ,
535540 )
536541
537542 debug ("figure out expected copy number" )
@@ -556,7 +561,8 @@ def _gene_cnv_frequencies_advanced(
556561 debug ("build event count and nobs for each cohort" )
557562 for cohort_index , cohort in enumerate (df_cohorts .itertuples ()):
558563 # construct grouping key
559- cohort_key = cohort .taxon , cohort .area , cohort .period
564+ cohort_taxon = getattr (cohort , taxon_by )
565+ cohort_key = cohort_taxon , cohort .area , cohort .period
560566
561567 # obtain sample indices for cohort
562568 sample_indices = group_samples_by_cohort .indices [cohort_key ]
0 commit comments