Spaces:
Running
Running
supercat666
commited on
Commit
•
fe2a0c6
1
Parent(s):
aea8c18
fix
Browse files
cas9on.py
CHANGED
@@ -208,9 +208,11 @@ def create_bigwig(df, bigwig_path):
|
|
208 |
if not all(column in df.columns for column in ["Chr", "Start Pos", "End Pos", "Prediction"]):
|
209 |
raise ValueError("DataFrame must contain 'Chr', 'Start Pos', 'End Pos', and 'Prediction' columns.")
|
210 |
|
211 |
-
#
|
|
|
|
|
212 |
chr_sizes = df.groupby('Chr')['End Pos'].max().to_dict()
|
213 |
-
header = [(chr, size) for chr, size in chr_sizes.items()]
|
214 |
|
215 |
# Create a BigWig file
|
216 |
bw = pyBigWig.open(bigwig_path, "w")
|
@@ -218,7 +220,7 @@ def create_bigwig(df, bigwig_path):
|
|
218 |
|
219 |
# Add entries to the BigWig file
|
220 |
for _, row in df.iterrows():
|
221 |
-
bw.addEntries([row['Chr']], [
|
222 |
|
223 |
# Close the BigWig file
|
224 |
-
bw.close()
|
|
|
208 |
if not all(column in df.columns for column in ["Chr", "Start Pos", "End Pos", "Prediction"]):
|
209 |
raise ValueError("DataFrame must contain 'Chr', 'Start Pos', 'End Pos', and 'Prediction' columns.")
|
210 |
|
211 |
+
# Convert positions to integers and prepare the BigWig header
|
212 |
+
df['Start Pos'] = df['Start Pos'].astype(int)
|
213 |
+
df['End Pos'] = df['End Pos'].astype(int)
|
214 |
chr_sizes = df.groupby('Chr')['End Pos'].max().to_dict()
|
215 |
+
header = [(chr, int(size)) for chr, size in chr_sizes.items()]
|
216 |
|
217 |
# Create a BigWig file
|
218 |
bw = pyBigWig.open(bigwig_path, "w")
|
|
|
220 |
|
221 |
# Add entries to the BigWig file
|
222 |
for _, row in df.iterrows():
|
223 |
+
bw.addEntries([row['Chr']], [row['Start Pos']], ends=[row['End Pos']], values=[float(row['Prediction'])])
|
224 |
|
225 |
# Close the BigWig file
|
226 |
+
bw.close()
|