Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Dnase
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
gencode_counts
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
# Dnase
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
gencode_counts
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
gencode_counts
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
self.meta_feat
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
def __getitem__(self, idx):
if self.fasta_extractor is None:
self.fasta_extractor = FastaExtractor(self.fasta_file)
interval = self.bt[idx]
if interval.stop - interval.start != self.SEQ_WIDTH:
raise ValueError("Expected the interval to be {0} wide. Recieved stop - start = {1}".
format(self.SEQ_WIDTH, interval.stop - interval.start))
# Run the fasta extractor
seq = np.squeeze(self.fasta_extractor([interval]), axis=0)
return {
"inputs": seq,
"targets": {}, # No Targets
"metadata": {
"ranges": GenomicRanges.from_interval(interval)
}
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
gencode_counts
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
# Dnase
dnase = np.squeeze(self.dnase_extractor([interval], axis=0))[:, np.newaxis]
dnase[np.isnan(dnase)] = 0 # NA fill
dnase_rc = dnase[::-1]
bigwig_list = [seq]
bigwig_rc_list = [seq_rc]
mappability = np.squeeze(self.mappability_extractor([interval], axis=0))[:, np.newaxis]
mappability[np.isnan(mappability)] = 0 # NA fill
mappability_rc = mappability[::-1]
bigwig_list.append(mappability)
bigwig_rc_list.append(mappability_rc)
bigwig_list.append(dnase)
bigwig_rc_list.append(dnase_rc)
ranges = GenomicRanges.from_interval(interval)
ranges_rc = GenomicRanges.from_interval(interval)
ranges_rc.strand = "-"
return {
"inputs": [
np.concatenate(bigwig_list, axis=-1), # stack along the last axis
np.concatenate(bigwig_rc_list, axis=-1), # RC version
],
"targets": {}, # No Targets
"metadata": {
"ranges": ranges,
"ranges_rc": ranges_rc
}
# check targets is none, pass targets file
if interval.name is not None:
y = np.array([float(interval.name)])
else:
y = {}
# Run the fasta extractor
seq = np.squeeze(self.fasta_extractor([interval]))
# Reformat so that it matches the Basset shape
# seq = np.swapaxes(seq, 1, 0)[:,:,None]
return {
"inputs": {"data/genome_data_dir": seq},
"targets": y,
"metadata": {
"ranges": GenomicRanges.from_interval(interval)
}