Skip to content

Instantly share code, notes, and snippets.

View timedreamer's full-sized avatar

Ji Huang timedreamer

View GitHub Profile
@timedreamer
timedreamer / .gitgnore
Last active March 4, 2026 05:22
A general .gitignore file for python DS projects.
archive/
# Python
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
@timedreamer
timedreamer / AGENTS.md
Last active March 4, 2026 05:22
For Python projects. Update 20260224

Repository Guidelines

Scope & Precedence

  • Apply these rules unless directly overridden by user instruction.
  • Conflict order: (1) user instruction, (2) this guide, (3) generic assistant defaults.

Documentation

  • Save markdown files under doc/.
  • Sub-folders under doc/ are allowed.
  • Prefix plan/summary filenames with YYYYMMDD (example: 20260219_implementation_summary.md).
@timedreamer
timedreamer / microgpt.py
Created February 12, 2026 17:44 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference 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
@timedreamer
timedreamer / .lintr
Created March 23, 2024 00:04 — forked from strengejacke/.lintr
VS Code setup for R
// 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))
@timedreamer
timedreamer / example_bar_plot.R
Created February 28, 2023 19:22 — forked from raryskin/example_bar_plot.R
quick example of a (not ugly) ggplot bar graph with points for individual subjects and error bars
# example of bar plot with individual subject points for Anya -04/24/2019
# added error bars - 04/25/2019
library(tidyverse) #will need to install this first (run: install.packages("tidyverse"))
## fake data
data = tibble( # creating a dataframe (aka "tibble") called data
subject = rep(1:10,times = 2 ), # making a column/vector of subject numbers (1-10) x2
condition = rep(c("hard", "easy"), each = 10), # making a column/vector of condition names
@timedreamer
timedreamer / Plot_muli-plots_on_multi-page.R
Created January 13, 2023 01:24
It's useful to plot many gene expression plots on a pdf. Each page has 3x3 or 4x4 plots.
# Thanks for the suggestion from Joseph Elsherbini.
library(tidyverse)
library(ggforce)
n_pages(p) # use this to get the number of pages to print
# then run a for loop to loop over pages
pdf("test.pdf")
for (i in 1:5) {
@timedreamer
timedreamer / GO_anlaysis_using_topGO.R
Created December 14, 2022 19:56
Use topGO package for GO analysis in R.
# 0. Prep -----------------------------------------------------------------
library(tidyverse)
library(here)
# 1. Load and clean EggNOG output -----------------------------------------
## The output was downloaded from the eggnog-mapper online run.
eggnog_go <- read_tsv(here("data", "misc", "out.emapper.annotations.gz"),
skip = 4) %>%
@timedreamer
timedreamer / download _json_ffq.py
Created September 21, 2022 08:49
Download sequenncing file meta data using `ffq`
# Download meta data using ffq.
# Need input `SraRunTable.txt`
# Author: Ji Huang
# Date: 2022-09-21
import pandas as pd
import subprocess
import os
@timedreamer
timedreamer / GENIE3_quick_test.R
Created January 6, 2022 19:11
Test using different Regulator or Targets in GENIE3, do I get the same output. It depends. Regulator-No; Target-Yes.
# Test on GENIE3 whether
# (Q1) if using more genes as regulator, for the same regulator-target edge
# do I get the same order? No. The edge order will be different.
# (Q2) if using more genes as targets, for the same regulator-target edges,
# do I get the same order? Yes. The same edge will have the exact same weight.
# Author: Ji Huang
# Date: 2021-01-06
@timedreamer
timedreamer / theme_jh.R
Last active March 17, 2021 14:34
The ggplot theme I updated based on theme_bw().
library(ggplot2)
theme_jh <- function (base_size = 11, base_family = "Arial",
base_line_size = base_size/22,
base_rect_size = base_size/22) {
theme_grey(base_size = base_size, base_family = base_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size) +
theme(panel.background = element_rect(fill = "white", colour = NA),
panel.border = element_rect(fill = NA, colour = "grey20"),
panel.grid = element_line(colour = "grey92"),