@@ -537,7 +537,7 @@ def _ensure_1d(name, arr, target_len):
537537 summary_path = f"{ output_dir } /protein_gene_correlation_summary.csv"
538538 if not overwrite :
539539 try :
540- with fs_out .open (f"{ out_dir_path } protein_gene_correlation_summary.csv" , 'r' ) as f :
540+ with fs_out .open (f"{ out_dir_path } / protein_gene_correlation_summary.csv" , 'r' ) as f :
541541 old_summary_df = pd .read_csv (f )
542542 except FileNotFoundError :
543543 old_summary_df = None
@@ -555,20 +555,20 @@ def _ensure_1d(name, arr, target_len):
555555 # Check if outputs exist and skip if not overwrite
556556 if not overwrite :
557557 try :
558- file_exists_csv = fs_out .exists (f"{ out_dir_path } { pair_csv_name } " )
558+ file_exists_csv = fs_out .exists (f"{ out_dir_path } / { pair_csv_name } " )
559559 except Exception :
560560 # If fs doesn't support exists, attempt open
561561 try :
562- ftest = fs_out .open (f"{ out_dir_path } { pair_csv_name } " , 'rb' )
562+ ftest = fs_out .open (f"{ out_dir_path } / { pair_csv_name } " , 'rb' )
563563 ftest .close ()
564564 file_exists_csv = True
565565 except Exception :
566566 file_exists_csv = False
567567 try :
568- file_exists_png = fs_out .exists (f"{ out_dir_path } { pair_png_name } " )
568+ file_exists_png = fs_out .exists (f"{ out_dir_path } / { pair_png_name } " )
569569 except Exception :
570570 try :
571- ftest = fs_out .open (f"{ out_dir_path } { pair_png_name } " , 'rb' )
571+ ftest = fs_out .open (f"{ out_dir_path } / { pair_png_name } " , 'rb' )
572572 ftest .close ()
573573 file_exists_png = True
574574 except Exception :
@@ -652,7 +652,7 @@ def _ensure_1d(name, arr, target_len):
652652 ax .grid (True , linestyle = '--' , alpha = 0.5 )
653653 fig .tight_layout ()
654654 # Write image to file (using fsspec)
655- with fs_out .open (f"{ out_dir_path } { pair_png_name } " , 'wb' ) as f :
655+ with fs_out .open (f"{ out_dir_path } / { pair_png_name } " , 'wb' ) as f :
656656 fig .savefig (f , format = 'png' , dpi = 300 )
657657 finally :
658658 plt .close (fig )
@@ -672,7 +672,7 @@ def _ensure_1d(name, arr, target_len):
672672 })
673673 pair_df = pd .DataFrame (records , columns = ["bin_y" , "bin_x" , "n_cells" , "transcript_count" , "transcript_density" , "protein_avg_intensity" ])
674674 # Save to CSV
675- with fs_out .open (f"{ out_dir_path } { pair_csv_name } " , 'w' ) as f :
675+ with fs_out .open (f"{ out_dir_path } / { pair_csv_name } " , 'w' ) as f :
676676 pair_df .to_csv (f , index = False )
677677
678678 # If any pairs were skipped and not added to summary_records (due to missing old summary data), handle them:
@@ -685,7 +685,7 @@ def _ensure_1d(name, arr, target_len):
685685 safe_gene = gene_name .replace (os .sep , "_" ).replace (" " , "_" )
686686 pair_csv_name = f"{ safe_prot } _{ safe_gene } _correlation.csv"
687687 try :
688- with fs_out .open (f"{ out_dir_path } { pair_csv_name } " , 'r' ) as f :
688+ with fs_out .open (f"{ out_dir_path } / { pair_csv_name } " , 'r' ) as f :
689689 df = pd .read_csv (f )
690690 # We assume the CSV was produced by this function in a previous run and contains needed columns
691691 if "transcript_density" in df .columns and "protein_avg_intensity" in df .columns and "n_cells" in df .columns :
@@ -718,7 +718,7 @@ def _ensure_1d(name, arr, target_len):
718718 summary_df = pd .concat ([summary_df , pd .DataFrame ([rec ])], ignore_index = True )
719719
720720 # Save summary CSV
721- with fs_out .open (f"{ out_dir_path } protein_gene_correlation_summary.csv" , 'w' ) as f :
721+ with fs_out .open (f"{ out_dir_path } / protein_gene_correlation_summary.csv" , 'w' ) as f :
722722 summary_df .to_csv (f , index = False )
723723
724724 return summary_df
0 commit comments