@@ -129,23 +129,23 @@ def plot_gaussian_fit(z_results: ZResult, facet_titles: bool = True, x_min: int
129129
130130
131131# Main function for protein abundance transformation
132- def protein_transform_main (abundance_df : pd .DataFrame | str | Path , out_dir : str | Path , group_name : str ) -> None :
132+ def protein_transform_main (
133+ abundance_df : pd .DataFrame | str | Path ,
134+ output_gaussian_img_filepath : Path ,
135+ output_z_score_matrix_filepath : Path ,
136+ ) -> None :
133137 """Transform protein abundance data."""
134- out_dir : Path = Path (out_dir )
135- output_figure_directory = out_dir / "figures"
136- output_figure_directory .mkdir (parents = True , exist_ok = True )
137-
138138 abundance_df : pd .DataFrame = (
139139 pd .read_csv (abundance_df ) if isinstance (abundance_df , (str , Path )) else abundance_df .fillna (0 )
140140 )
141141 abundance_df = abundance_df [np .isfinite (abundance_df ).all (axis = 1 )] # Remove +/- infinity values
142142 z_transform : ZResult = z_score_calc (abundance_df , min_thresh = 0 )
143143
144144 fig = plot_gaussian_fit (z_results = z_transform , facet_titles = True , x_min = - 4 )
145- fig .write_image (out_dir / "gaussian_fit .png" )
146- fig .write_html (out_dir / "gaussian_fit .html" )
147- logger .info (f"Wrote image to { out_dir / 'gaussian_fit.png' } " )
145+ fig .write_image (output_gaussian_img_filepath . with_suffix ( " .png") )
146+ fig .write_html (output_gaussian_img_filepath . with_suffix ( " .html") )
147+ logger .info (f"Gaussian fit figure written to { output_gaussian_img_filepath } " )
148148
149149 z_transformed_abundances = z_transform .zfpkm
150150 z_transformed_abundances [abundance_df == 0 ] = - 4
151- z_transformed_abundances .to_csv (out_dir / f"protein_zscore_Matrix_ { group_name } .csv" , index = False )
151+ z_transformed_abundances .to_csv (output_z_score_matrix_filepath , index = False )
0 commit comments