update the return values for cage and regulatory elements
Browse files- genomics-long-range-benchmark.py +25 -13
genomics-long-range-benchmark.py
CHANGED
@@ -175,9 +175,9 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
175 |
# chromosome number
|
176 |
"chromosome": datasets.Value(dtype="string"),
|
177 |
# start
|
178 |
-
"
|
179 |
# stop
|
180 |
-
"
|
181 |
}
|
182 |
)
|
183 |
return datasets.DatasetInfo(
|
@@ -261,11 +261,12 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
261 |
|
262 |
chromosome = row['chrom']
|
263 |
|
264 |
-
padded_sequence = pad_sequence(
|
265 |
chromosome=self.reference_genome[chromosome],
|
266 |
start=start,
|
267 |
sequence_length=self.sequence_length,
|
268 |
end=stop,
|
|
|
269 |
)
|
270 |
|
271 |
# floor npy_idx to the nearest 1000
|
@@ -291,8 +292,8 @@ class CagePredictionHandler(GenomicLRATaskHandler):
|
|
291 |
"labels": targets,
|
292 |
"sequence": standardize_sequence(padded_sequence),
|
293 |
"chromosome": re.sub("chr", "", chromosome),
|
294 |
-
"
|
295 |
-
"
|
296 |
}
|
297 |
key += 1
|
298 |
|
@@ -701,8 +702,10 @@ class ChromatinFeaturesHandler(GenomicLRATaskHandler):
|
|
701 |
"labels": datasets.Sequence(datasets.Value("int8")),
|
702 |
# chromosome number
|
703 |
"chromosome": datasets.Value(dtype="string"),
|
704 |
-
# position
|
705 |
-
"
|
|
|
|
|
706 |
}
|
707 |
)
|
708 |
return datasets.DatasetInfo(
|
@@ -755,7 +758,8 @@ class ChromatinFeaturesHandler(GenomicLRATaskHandler):
|
|
755 |
"labels": labels_row,
|
756 |
"sequence": standardize_sequence(padded_sequence),
|
757 |
"chromosome": re.sub("chr", "", chromosome),
|
758 |
-
"
|
|
|
759 |
}
|
760 |
key += 1
|
761 |
|
@@ -808,9 +812,9 @@ class RegulatoryElementHandler(GenomicLRATaskHandler):
|
|
808 |
# chromosome number
|
809 |
"chromosome": datasets.Value(dtype="string"),
|
810 |
# start
|
811 |
-
"
|
812 |
# stop
|
813 |
-
"
|
814 |
}
|
815 |
)
|
816 |
return datasets.DatasetInfo(
|
@@ -866,8 +870,8 @@ class RegulatoryElementHandler(GenomicLRATaskHandler):
|
|
866 |
"labels": label,
|
867 |
"sequence": standardize_sequence(padded_sequence),
|
868 |
"chromosome": re.sub("chr", "", chromosome),
|
869 |
-
"
|
870 |
-
"
|
871 |
}
|
872 |
key += 1
|
873 |
|
@@ -962,7 +966,8 @@ def standardize_sequence(sequence: str):
|
|
962 |
return sequence
|
963 |
|
964 |
|
965 |
-
def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=False
|
|
|
966 |
"""
|
967 |
Extends a given sequence to length sequence_length. If
|
968 |
padding to the given length is outside the gene, returns
|
@@ -989,5 +994,12 @@ def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=F
|
|
989 |
if start < 0 or end >= len(chromosome):
|
990 |
return
|
991 |
if negative_strand:
|
|
|
|
|
|
|
992 |
return chromosome[start:end].reverse.complement.seq
|
|
|
|
|
|
|
|
|
993 |
return chromosome[start:end].seq
|
|
|
175 |
# chromosome number
|
176 |
"chromosome": datasets.Value(dtype="string"),
|
177 |
# start
|
178 |
+
"labels_start": datasets.Value(dtype="int32"),
|
179 |
# stop
|
180 |
+
"labels_stop": datasets.Value(dtype="int32")
|
181 |
}
|
182 |
)
|
183 |
return datasets.DatasetInfo(
|
|
|
261 |
|
262 |
chromosome = row['chrom']
|
263 |
|
264 |
+
padded_sequence,new_start,new_stop = pad_sequence(
|
265 |
chromosome=self.reference_genome[chromosome],
|
266 |
start=start,
|
267 |
sequence_length=self.sequence_length,
|
268 |
end=stop,
|
269 |
+
return_new_start_stop=True
|
270 |
)
|
271 |
|
272 |
# floor npy_idx to the nearest 1000
|
|
|
292 |
"labels": targets,
|
293 |
"sequence": standardize_sequence(padded_sequence),
|
294 |
"chromosome": re.sub("chr", "", chromosome),
|
295 |
+
"labels_start": new_start,
|
296 |
+
"labels_stop": new_stop
|
297 |
}
|
298 |
key += 1
|
299 |
|
|
|
702 |
"labels": datasets.Sequence(datasets.Value("int8")),
|
703 |
# chromosome number
|
704 |
"chromosome": datasets.Value(dtype="string"),
|
705 |
+
# starting position in genome which corresponds to label
|
706 |
+
"label_start": datasets.Value(dtype="int32"),
|
707 |
+
# end position in genome which corresponds to label
|
708 |
+
"label_stop": datasets.Value(dtype="int32"),
|
709 |
}
|
710 |
)
|
711 |
return datasets.DatasetInfo(
|
|
|
758 |
"labels": labels_row,
|
759 |
"sequence": standardize_sequence(padded_sequence),
|
760 |
"chromosome": re.sub("chr", "", chromosome),
|
761 |
+
"label_start": coordinates_row['POS']-100,
|
762 |
+
"label_stop": coordinates_row['POS'] + 99,
|
763 |
}
|
764 |
key += 1
|
765 |
|
|
|
812 |
# chromosome number
|
813 |
"chromosome": datasets.Value(dtype="string"),
|
814 |
# start
|
815 |
+
"label_start": datasets.Value(dtype="int32"),
|
816 |
# stop
|
817 |
+
"label_stop": datasets.Value(dtype="int32"),
|
818 |
}
|
819 |
)
|
820 |
return datasets.DatasetInfo(
|
|
|
870 |
"labels": label,
|
871 |
"sequence": standardize_sequence(padded_sequence),
|
872 |
"chromosome": re.sub("chr", "", chromosome),
|
873 |
+
"label_start": coordinates_row["START"],
|
874 |
+
"label_stop": coordinates_row["STOP"]
|
875 |
}
|
876 |
key += 1
|
877 |
|
|
|
966 |
return sequence
|
967 |
|
968 |
|
969 |
+
def pad_sequence(chromosome, start, sequence_length, end=None, negative_strand=False,
|
970 |
+
return_new_start_stop=False):
|
971 |
"""
|
972 |
Extends a given sequence to length sequence_length. If
|
973 |
padding to the given length is outside the gene, returns
|
|
|
994 |
if start < 0 or end >= len(chromosome):
|
995 |
return
|
996 |
if negative_strand:
|
997 |
+
if return_new_start_stop:
|
998 |
+
return chromosome[start:end].reverse.complement.seq ,start, end
|
999 |
+
|
1000 |
return chromosome[start:end].reverse.complement.seq
|
1001 |
+
|
1002 |
+
if return_new_start_stop:
|
1003 |
+
return chromosome[start:end].seq , start, end
|
1004 |
+
|
1005 |
return chromosome[start:end].seq
|