Create cache folder
#3
by pbordesinstadeep - opened
124 unmodified lines12512612712812913013113213313413513613713812812913071 unmodified lines20220320421620520620723 unmodified lines23123223324623423523625023723823925324024124224324424524624724824925825025125226226325325425526526626725625725825926026123 unmodified lines28528628728828929029129229326 unmodified lines3203213223303313323233243253353363373383263273413423433443453463473483493503513523533283293303313323333343353363373383393403413423433443453463473483493505 unmodified lines356357358365359360361362139 unmodified lines502503504511505124 unmodified lines "Whole Blood",]
# Add after LABELS_V2 definitionLABELS_LIGHT = [ "Adipose Tissue", "Brain", "Heart", "Liver", "Lung", "Muscle", "Pancreas", "Skin",]
class GenomicLRATaskHandler(ABC): """71 unmodified lines
if not os.path.exists(file_complete_path): if not os.path.exists(file_complete_path + ".gz"): os.makedirs(os.path.dirname(file_complete_path), exist_ok=True) with tqdm( unit="B", unit_scale=True,23 unmodified lines sequence_length: int = DEFAULT_LENGTH, filter_out_sequence_length: int = DEFAULT_FILTER_OUT_LENGTH, expression_method: str = "read_counts_old", light_version: bool = False, **kwargs, ): """ Creates a new handler for the Transcript Expression Prediction Task. Creates a new handler for the Transcrpt Expression Prediction Task. Args: sequence_length: Length of the sequence around the TSS_CAGE start site light_version: If True, uses a smaller subset of tissues and fewer samples Instance Vars: reference_genome: The Fasta extracted reference genome. coordinate_csv_file: The csv file that stores the coordinates and filename of the target labels_csv_file: The csv file that stores the labels with one sample per row. sequence_length: Sequence length for this handler. counts. """ self.reference_genome = None self.coordinate_csv_file = None self.labels_csv_file = None self.light_version = light_version self.sequence_length = sequence_length self.filter_out_sequence_length = filter_out_sequence_length
if self.filter_out_sequence_length is not None: assert isinstance(self.filter_out_sequence_length, int) if filter_out_sequence_length is not None: assert isinstance(filter_out_sequence_length, int) assert ( self.sequence_length <= self.filter_out_sequence_length ), f"{self.sequence_length=} > {self.filter_out_sequence_length=}" assert isinstance(self.sequence_length, int) sequence_length <= filter_out_sequence_length ), f"{sequence_length=} > {filter_out_sequence_length=}" assert isinstance(sequence_length, int)
def get_info(self, description: str) -> DatasetInfo: """23 unmodified lines } ) return datasets.DatasetInfo( # This is the description that will appear on the datasets page. description=description, # This defines the different columns of the dataset and their types features=features, )
26 unmodified lines """ df = pd.read_csv(self.df_csv_file) df = df.loc[df["chr"] != "chrMT"] # Use light version labels if specified labels_name = LABELS_LIGHT if self.light_version else LABELS_V1 labels_name = LABELS_V1
split_df = df.loc[df["split"] == split] # For light version, take only a subset of the data if self.light_version: split_df = split_df.sample(n=min(1000, len(split_df)), random_state=42)
norm_values_df = pd.read_csv(self.normalization_values_csv_file) # Select appropriate columns based on version label_columns = [f"m_t_{tissue}" for tissue in labels_name] m_t = norm_values_df[label_columns].to_numpy().reshape(-1) label_columns = [f"sigma_t_{tissue}" for tissue in labels_name] sigma_t = norm_values_df[label_columns].to_numpy().reshape(-1) label_columns = [f"m_g_{tissue}" for tissue in labels_name] m_g = norm_values_df[label_columns].to_numpy().reshape(-1) label_columns = [f"sigma_g_{tissue}" for tissue in labels_name] sigma_g = norm_values_df[label_columns].to_numpy().reshape(-1) m_t = ( norm_values_df[[f"m_t_{tissue}" for tissue in LABELS_V1]] .to_numpy() .reshape(-1) ) sigma_t = ( norm_values_df[[f"sigma_t_{tissue}" for tissue in LABELS_V1]] .to_numpy() .reshape(-1) ) m_g = ( norm_values_df[[f"m_g_{tissue}" for tissue in LABELS_V1]] .to_numpy() .reshape(-1) ) sigma_g = ( norm_values_df[[f"sigma_g_{tissue}" for tissue in LABELS_V1]] .to_numpy() .reshape(-1) )
key = 0 for idx, coordinates_row in split_df.iterrows():5 unmodified lines start = coordinates_row["start"] - 1 # -1 since vcf coords are 1-based
chromosome = coordinates_row["chr"] labels_row = coordinates_row[labels_name] labels_row = coordinates_row[LABELS_V1] padded_sequence = pad_sequence( chromosome=self.reference_genome[chromosome], start=start,139 unmodified lines
if negative_strand: return chromosome[start:end].reverse.complement.seq return chromosome[start:end].seq return chromosome[start:end].seqmulti_omics_transcript_expression.py+37-43