File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -803,27 +803,14 @@ async def _process(
803803 output_zfpkm_plot_dirpath = output_zfpkm_plot_dirpath ,
804804 )
805805
806- merged_zscore_df = pd .DataFrame ()
807- expressed_genes : list [str ] = []
808- top_genes : list [str ] = []
809- for metric in metrics .values ():
810- expressed_genes .extend (metric .entrez_gene_ids )
811- top_genes .extend (metric .high_confidence_entrez_gene_ids )
812-
813- merged_zscore_df = (
814- metric .z_score_matrix
815- if merged_zscore_df .empty
816- else merged_zscore_df .merge (
817- metric .z_score_matrix ,
818- how = "outer" ,
819- left_index = True ,
820- right_index = True ,
821- )
822- )
823- merged_zscore_df [merged_zscore_df .isna ()] = - 4
806+ merged_zscore_df = pd .concat ([m .z_score_matrix [m .z_score_matrix .index != "-" ] for m in metrics .values ()], axis = "columns" )
807+ merged_zscore_df .fillna (- 4 , inplace = True )
808+ expressed_genes : list [str ] = list (itertools .chain .from_iterable (m .entrez_gene_ids for m in metrics .values ()))
809+ top_genes : list [str ] = list (itertools .chain .from_iterable (m .high_confidence_entrez_gene_ids for m in metrics .values ()))
824810
825811 # If any of the normalization metrics are not empty, write the normalized metrics to disk
826812 if not all (metric .normalization_matrix .empty for metric in metrics .values ()):
813+ merged_zscore_df : pd .DataFrame = merged_zscore_df .reindex (columns = sorted (merged_zscore_df ))
827814 merged_zscore_df .to_csv (output_zscore_normalization_filepath , index = True )
828815 logger .success (f"Wrote z-score normalization matrix to { output_zscore_normalization_filepath } " )
829816 else :
You can’t perform that action at this time.
0 commit comments