Spaces:
Sleeping
Sleeping
supercat666
commited on
Commit
•
b31c7ac
1
Parent(s):
544275a
fix
Browse files
cas9on.py
CHANGED
@@ -208,19 +208,18 @@ def create_bigwig(df, bigwig_path):
|
|
208 |
df = pd.DataFrame(df, columns=["Chr", "Start Pos", "End Pos", "Strand", "Transcript", "Exon", "Target", "gRNA", "Prediction"])
|
209 |
|
210 |
# Calculate chromosome sizes as the maximum end position per chromosome
|
211 |
-
# Ensure the sizes are integers
|
212 |
chrom_sizes = df.groupby('Chr')['End Pos'].max().astype(int).to_dict()
|
213 |
|
214 |
with pyBigWig.open(bigwig_path, "w") as bw:
|
215 |
-
# Add chromosome sizes to the header
|
216 |
bw.addHeader([(chr, size) for chr, size in chrom_sizes.items()])
|
217 |
|
218 |
-
# Iterate over
|
219 |
for chrom in df['Chr'].unique():
|
220 |
chrom_df = df[df['Chr'] == chrom]
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
208 |
df = pd.DataFrame(df, columns=["Chr", "Start Pos", "End Pos", "Strand", "Transcript", "Exon", "Target", "gRNA", "Prediction"])
|
209 |
|
210 |
# Calculate chromosome sizes as the maximum end position per chromosome
|
|
|
211 |
chrom_sizes = df.groupby('Chr')['End Pos'].max().astype(int).to_dict()
|
212 |
|
213 |
with pyBigWig.open(bigwig_path, "w") as bw:
|
214 |
+
# Add chromosome sizes to the header
|
215 |
bw.addHeader([(chr, size) for chr, size in chrom_sizes.items()])
|
216 |
|
217 |
+
# Iterate over the DataFrame and add entries for each chromosome
|
218 |
for chrom in df['Chr'].unique():
|
219 |
chrom_df = df[df['Chr'] == chrom]
|
220 |
+
starts = chrom_df['Start Pos'].astype(int).tolist()
|
221 |
+
ends = chrom_df['End Pos'].astype(int).tolist()
|
222 |
+
values = chrom_df['Prediction'].astype(float).tolist()
|
223 |
+
|
224 |
+
if starts and ends and values:
|
225 |
+
bw.addEntries(chrom, starts, ends=ends, values=values)
|