supercat666 commited on
Commit
8e874ac
1 Parent(s): 3b32f3b
Files changed (1) hide show
  1. cas9on.py +5 -13
cas9on.py CHANGED
@@ -202,10 +202,6 @@ def process_gene(gene_symbol, model_path):
202
  # def create_csv_from_df(df, output_path):
203
  # df.to_csv(output_path, index=False)
204
 
205
-
206
- import pyBigWig
207
-
208
-
209
  def create_bigwig(df, bigwig_path):
210
  # Check for required columns in the DataFrame
211
  required_columns = ["Chr", "Start Pos", "End Pos", "Prediction"]
@@ -229,15 +225,11 @@ def create_bigwig(df, bigwig_path):
229
  bw.addHeader(header)
230
 
231
  # Add entries for each chromosome
232
- for chr in sorted(chr_sizes.keys()):
233
- chrom_df = df[df['Chr'] == chr]
234
- starts = chrom_df['Start Pos'].tolist()
235
- ends = chrom_df['End Pos'].tolist()
236
- values = chrom_df['Prediction'].tolist()
237
-
238
- # Ensure data is in the correct order and format
239
- if starts and ends and values:
240
- bw.addEntries(chr, starts, ends=ends, values=values)
241
 
242
  # Close the BigWig file
243
  bw.close()
 
202
  # def create_csv_from_df(df, output_path):
203
  # df.to_csv(output_path, index=False)
204
 
 
 
 
 
205
  def create_bigwig(df, bigwig_path):
206
  # Check for required columns in the DataFrame
207
  required_columns = ["Chr", "Start Pos", "End Pos", "Prediction"]
 
225
  bw.addHeader(header)
226
 
227
  # Add entries for each chromosome
228
+ for chr, group in df.groupby('Chr'):
229
+ starts = group['Start Pos'].tolist()
230
+ ends = group['End Pos'].tolist()
231
+ values = group['Prediction'].astype(float).tolist()
232
+ bw.addEntries(str(chr), starts, ends=ends, values=values)
 
 
 
 
233
 
234
  # Close the BigWig file
235
  bw.close()