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
| """ | |
| The most atomic way to train and run inference for a GPT in pure, dependency-free Python. | |
| This file is the complete algorithm. | |
| Everything else is just efficiency. | |
| @karpathy | |
| """ | |
| import os # os.path.exists | |
| import math # math.log, math.exp |
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 necessary libraries | |
| import pandas as pd | |
| from rdkit import Chem | |
| from rdkit.Chem import rdMMPA | |
| from collections import defaultdict | |
| import logging | |
| # Configure logging | |
| logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
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
| # Demo 1: NLP ------------------------------------------------------------- | |
| # Load reticulate, declare that we'll use pytorch and huggingface transformers | |
| library(reticulate) | |
| py_require("torch") | |
| py_require("transformers") | |
| # Use the transformers python, and use the sentiment analysis pipeline | |
| transformers <- import("transformers") | |
| analyzer <- transformers$pipeline("sentiment-analysis") |
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
| library(splines) | |
| library(DESeq2) | |
| # make some demo data | |
| dds <- makeExampleDESeqDataSet(n=100, m=40) | |
| dds$condition <- sort(runif(40)) | |
| # make one gene where expression has a curve shape (just for demo) | |
| s_shape <- round(500 * sin(dds$condition*2*pi) + 1000 + rnorm(40,0,50)) | |
| mode(s_shape) <- "integer" | |
| counts(dds)[1,] <- s_shape |
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
| # Function to run to check if you have any missing `\value{}` tags | |
| check_missing_value <- function(pkg = ".") { | |
| pkg_root <- rprojroot::find_package_root_file(path = pkg) | |
| # find exported functions | |
| ns <- readLines(file.path(pkg_root, "NAMESPACE")) | |
| exports <- ns[which(grepl("export", ns))] | |
| # https://stackoverflow.com/questions/8613237/extract-info-inside-all-parenthesis-in-r | |
| exported_fxs <- stringr::str_extract(exports, "(?<=\\().+?(?=\\))") | |
| # parse all man pages |
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
| // save to windows-user directory | |
| linters: with_defaults(object_name_linter = NULL, | |
| object_length_linter(50), | |
| commented_code_linter = NULL, | |
| object_usage_linter = NULL, | |
| line_length_linter(120), | |
| cyclocomp_linter = cyclocomp_linter(50)) |
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
| format = """ | |
| [\uE0B6](fg:#1C4961)[$directory](bg:#1C4961)[\uE0B0](fg:#1C4961 bg:#2F79A1)$git_branch[\uE0B0](fg:#2F79A1 bg:#3A95C7)$git_status[\uE0B0](#3A95C7 bg:#40A9E0)$time[\uE0B0](#40A9E0 bg:none) $all$character """ | |
| add_newline = true | |
| [directory] | |
| style = "bg:#1C4961 fg:white" | |
| [git_branch] | |
| format = "[ $symbol$branch ]($style)" |
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
| # This Makefile builds a shared version of the library, | |
| # libbz2.dylib for MacOSX x86 (10.13.4 or higher), | |
| # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). | |
| # It is a custom Makefile. Use at own risk. | |
| # Run in your MacOS terminal with the following command: | |
| # make -f Makefile-libbz2_dylib | |
| PKG_VERSION?=1.0.8 | |
| PREFIX?=/usr/local |
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
| library(recount) | |
| library(edgeR) | |
| #/ Get the counts from GTEx via recount as a SummarizedExperiment | |
| #/ => 1.3GB file | |
| options(timeout=600) | |
| download_study("SRP012682", type = "rse-gene") | |
| load(file.path("SRP012682", "rse_gene.Rdata")) | |
| #/ remove whitespaces in tissue names: |
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
| library(ggplot2) | |
| library(reshape2) | |
| library(egg) | |
| # thanks to https://stackoverflow.com/questions/1330989/rotating-and-spacing-axis-labels-in-ggplot2/60650595#60650595 | |
| dat<-reshape2::melt(data.frame(groupA=rnorm(20), | |
| groupB=rnorm(20), | |
| groupC=rnorm(20))) |
NewerOlder