😶🌫️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| # GTF files, e.g. https://ftp.ensembl.org/pub/current_gtf/homo_sapiens/Homo_sapiens.GRCh38.108.gtf.gz | |
| # README for GTF: https://ftp.ensembl.org/pub/current_gtf/homo_sapiens/README | |
| raw_df = pd.read_csv("some_file.gtf", sep="\t", comment="#", header=None) | |
| # Parse attributes from the last column | |
| # Example value: 'gene_id "ENSG00000160072"; gene_version "20"; gene_name "ATAD3B"; gene_source "ensembl_havana"; gene_biotype "protein_coding";' | |
| # First convert each to a dict: {'gene_id': 'ENSG00000160072', 'gene_version': '20', 'gene_name': 'ATAD3B', 'gene_source': 'ensembl_havana', 'gene_biotype': 'protein_coding'} | |
| # Then combine the list of dict into a dataframe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| torch.manual_seed(0) | |
| # Binary setting ############################################################## | |
| print(f"{'Setting up binary case':-^80}") | |
| z = torch.randn(5) | |
| yhat = torch.sigmoid(z) | |
| y = torch.Tensor([0, 1, 1, 0, 1]) | |
| print(f"{z=}\n{yhat=}\n{y=}\n{'':-^80}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torch.nn.functional as F | |
| torch.manual_seed(0) | |
| # Binary setting ############################################################## | |
| print(f"{'Setting up binary case':-^80}") | |
| z = torch.randn(5) | |
| yhat = torch.sigmoid(z) | |
| y = torch.Tensor([0, 1, 1, 0, 1]) |