Commit
·
8116cdb
1
Parent(s):
9ddea85
fix
Browse files
multi_omics_transcript_expression.py
CHANGED
|
@@ -154,7 +154,8 @@ class GenomicLRATaskHandler(ABC):
|
|
| 154 |
name=datasets.Split.TEST, gen_kwargs={"handler": self, "split": "test"}
|
| 155 |
),
|
| 156 |
datasets.SplitGenerator(
|
| 157 |
-
name=datasets.Split.VALIDATION,
|
|
|
|
| 158 |
),
|
| 159 |
]
|
| 160 |
|
|
@@ -219,8 +220,8 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 219 |
Handler for the Transcript Expression task.
|
| 220 |
"""
|
| 221 |
|
| 222 |
-
DEFAULT_LENGTH =
|
| 223 |
-
DEFAULT_FILTER_OUT_LENGTH =
|
| 224 |
|
| 225 |
def __init__(
|
| 226 |
self,
|
|
@@ -238,7 +239,6 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 238 |
coordinate_csv_file: The csv file that stores the coordinates and filename of the target
|
| 239 |
labels_csv_file: The csv file that stores the labels with one sample per row.
|
| 240 |
sequence_length: Sequence length for this handler.
|
| 241 |
-
expression_method: To specify if user wants to use TPMs instead of read
|
| 242 |
counts.
|
| 243 |
"""
|
| 244 |
self.reference_genome = None
|
|
@@ -246,7 +246,6 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 246 |
self.labels_csv_file = None
|
| 247 |
self.sequence_length = sequence_length
|
| 248 |
self.filter_out_sequence_length = filter_out_sequence_length
|
| 249 |
-
self.expression_method = expression_method
|
| 250 |
|
| 251 |
if filter_out_sequence_length is not None:
|
| 252 |
assert isinstance(filter_out_sequence_length, int)
|
|
@@ -266,6 +265,10 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 266 |
"DNA": datasets.Value("string"),
|
| 267 |
# list of expression values in each tissue
|
| 268 |
"labels": datasets.Sequence(datasets.Value("float32")),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
"labels_name": datasets.Sequence(datasets.Value("string")),
|
| 270 |
# chromosome number
|
| 271 |
"chromosome": datasets.Value(dtype="string"),
|
|
@@ -297,18 +300,12 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 297 |
)
|
| 298 |
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
"transcript_expression/GTEx_v1_multiomics.csv"
|
| 307 |
-
)
|
| 308 |
-
elif self.expression_method == "read_counts":
|
| 309 |
-
self.df_csv_file = dl_manager.download_and_extract(
|
| 310 |
-
"transcript_expression/GTEx_read_counts_multiomics.csv"
|
| 311 |
-
)
|
| 312 |
|
| 313 |
return super().split_generators(dl_manager, cache_dir_root)
|
| 314 |
|
|
@@ -324,12 +321,18 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 324 |
|
| 325 |
split_df = df.loc[df["split"] == split]
|
| 326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
key = 0
|
| 328 |
for idx, coordinates_row in split_df.iterrows():
|
| 329 |
negative_strand = coordinates_row["strand"] == "-"
|
| 330 |
|
| 331 |
if negative_strand:
|
| 332 |
-
start =
|
| 333 |
else:
|
| 334 |
start = coordinates_row["start"] - 1 # -1 since vcf coords are 1-based
|
| 335 |
|
|
@@ -342,12 +345,17 @@ class TranscriptExpressionHandler(GenomicLRATaskHandler):
|
|
| 342 |
negative_strand=negative_strand,
|
| 343 |
filter_out_sequence_length=self.filter_out_sequence_length,
|
| 344 |
)
|
|
|
|
| 345 |
if padded_sequence:
|
| 346 |
yield key, {
|
| 347 |
-
"transcript_id":coordinates_row["transcript_id_gtex"],
|
| 348 |
-
"gene_id":coordinates_row["gene_id_gtex"],
|
| 349 |
"labels_name": labels_name,
|
| 350 |
"labels": labels_row.to_numpy(),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
"DNA": standardize_sequence(padded_sequence),
|
| 352 |
"chromosome": re.sub("chr", "", chromosome),
|
| 353 |
"RNA": coordinates_row["RNA"],
|
|
|
|
| 154 |
name=datasets.Split.TEST, gen_kwargs={"handler": self, "split": "test"}
|
| 155 |
),
|
| 156 |
datasets.SplitGenerator(
|
| 157 |
+
name=datasets.Split.VALIDATION,
|
| 158 |
+
gen_kwargs={"handler": self, "split": "test"},
|
| 159 |
),
|
| 160 |
]
|
| 161 |
|
|
|
|
| 220 |
Handler for the Transcript Expression task.
|
| 221 |
"""
|
| 222 |
|
| 223 |
+
DEFAULT_LENGTH = 200_000
|
| 224 |
+
DEFAULT_FILTER_OUT_LENGTH = 196_608
|
| 225 |
|
| 226 |
def __init__(
|
| 227 |
self,
|
|
|
|
| 239 |
coordinate_csv_file: The csv file that stores the coordinates and filename of the target
|
| 240 |
labels_csv_file: The csv file that stores the labels with one sample per row.
|
| 241 |
sequence_length: Sequence length for this handler.
|
|
|
|
| 242 |
counts.
|
| 243 |
"""
|
| 244 |
self.reference_genome = None
|
|
|
|
| 246 |
self.labels_csv_file = None
|
| 247 |
self.sequence_length = sequence_length
|
| 248 |
self.filter_out_sequence_length = filter_out_sequence_length
|
|
|
|
| 249 |
|
| 250 |
if filter_out_sequence_length is not None:
|
| 251 |
assert isinstance(filter_out_sequence_length, int)
|
|
|
|
| 265 |
"DNA": datasets.Value("string"),
|
| 266 |
# list of expression values in each tissue
|
| 267 |
"labels": datasets.Sequence(datasets.Value("float32")),
|
| 268 |
+
"m_t": datasets.Sequence(datasets.Value("float32")),
|
| 269 |
+
"sigma_t": datasets.Sequence(datasets.Value("float32")),
|
| 270 |
+
"m_g": datasets.Sequence(datasets.Value("float32")),
|
| 271 |
+
"sigma_g": datasets.Sequence(datasets.Value("float32")),
|
| 272 |
"labels_name": datasets.Sequence(datasets.Value("string")),
|
| 273 |
# chromosome number
|
| 274 |
"chromosome": datasets.Value(dtype="string"),
|
|
|
|
| 300 |
)
|
| 301 |
self.reference_genome = Fasta(reference_genome_file, one_based_attributes=False)
|
| 302 |
|
| 303 |
+
self.df_csv_file = dl_manager.download_and_extract(
|
| 304 |
+
"transcript_expression/GTEx_final_tpm_multiomics_fix.csv"
|
| 305 |
+
)
|
| 306 |
+
self.normalization_values_csv_file = dl_manager.download_and_extract(
|
| 307 |
+
"transcript_expression/normalization_values.csv"
|
| 308 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
return super().split_generators(dl_manager, cache_dir_root)
|
| 311 |
|
|
|
|
| 321 |
|
| 322 |
split_df = df.loc[df["split"] == split]
|
| 323 |
|
| 324 |
+
norm_values_df = pd.read_csv(self.normalization_values_csv_file)
|
| 325 |
+
m_t = norm_values_df["m_t"]
|
| 326 |
+
sigma_t = norm_values_df["sigma_t"]
|
| 327 |
+
m_g = norm_values_df["m_g"]
|
| 328 |
+
sigma_g = norm_values_df["sigma_g"]
|
| 329 |
+
|
| 330 |
key = 0
|
| 331 |
for idx, coordinates_row in split_df.iterrows():
|
| 332 |
negative_strand = coordinates_row["strand"] == "-"
|
| 333 |
|
| 334 |
if negative_strand:
|
| 335 |
+
start = coordinates_row["end"] - 1
|
| 336 |
else:
|
| 337 |
start = coordinates_row["start"] - 1 # -1 since vcf coords are 1-based
|
| 338 |
|
|
|
|
| 345 |
negative_strand=negative_strand,
|
| 346 |
filter_out_sequence_length=self.filter_out_sequence_length,
|
| 347 |
)
|
| 348 |
+
fdsjog
|
| 349 |
if padded_sequence:
|
| 350 |
yield key, {
|
| 351 |
+
"transcript_id": coordinates_row["transcript_id_gtex"],
|
| 352 |
+
"gene_id": coordinates_row["gene_id_gtex"],
|
| 353 |
"labels_name": labels_name,
|
| 354 |
"labels": labels_row.to_numpy(),
|
| 355 |
+
"m_t": m_t.to_numpy(),
|
| 356 |
+
"sigma_t": sigma_t.to_numpy(),
|
| 357 |
+
"m_g": m_g.to_numpy(),
|
| 358 |
+
"sigma_g": sigma_g.to_numpy(),
|
| 359 |
"DNA": standardize_sequence(padded_sequence),
|
| 360 |
"chromosome": re.sub("chr", "", chromosome),
|
| 361 |
"RNA": coordinates_row["RNA"],
|