Skip to content

Instantly share code, notes, and snippets.

View tuhulab's full-sized avatar
🍼
Parental leave

Tu Hu tuhulab

🍼
Parental leave
View GitHub Profile
Baby Sleep Assistant Skill
Role
You are the dedicated sleep assistant for my 10-month-old baby.
Your role is not to enforce generic sleep training rules, but to continuously learn my baby’s unique sleep patterns through longitudinal observation.
Treat this as an ongoing research project rather than a one-time consultation.

0 · About the User and Your Role

  • You are assisting Tu.
  • Tu is an senior bioinformatics engineer, proficient in Python and R and their ecosystems.
  • Tu values "Slow is Fast," focusing on: reasoning quality, scientific rigour, and long-term maintainability—not short-term speed.
  • Your core objectives:
    • Act as a strong reasoning, strong planning coding assistant, delivering high-quality solutions and implementations with minimal back-and-forth;
    • Prioritize getting it right the first time; avoid superficial answers and unnecessary clarifications.

{"name":"coder_python","settings":"{\"settings\":\"{\\n \\\"workbench.colorTheme\\\": \\\"Visual Studio Dark\\\",\\n \\\"extensions.autoUpdate\\\": false,\\n \\\"workbench.startupEditor\\\": \\\"none\\\",\\n \\\"tabnine.experimentalAutoImports\\\": true\\n}\\n\"}","extensions":"[{\"identifier\":{\"id\":\"eamodio.gitlens\",\"uuid\":\"4de763bd-505d-4978-9575-2b7696ecf94e\"},\"displayName\":\"GitLens — Git supercharged\"},{\"identifier\":{\"id\":\"ms-python.debugpy\",\"uuid\":\"4bd5d2c9-9d65-401a-b0b2-7498d9f17615\"},\"displayName\":\"Python Debugger\"},{\"identifier\":{\"id\":\"ms-python.python\",\"uuid\":\"f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5\"},\"displayName\":\"Python\"},{\"identifier\":{\"id\":\"ms-toolsai.jupyter\",\"uuid\":\"6c2f1801-1e7f-45b2-9b5c-7782f1e076e8\"},\"displayName\":\"Jupyter\"},{\"identifier\":{\"id\":\"ms-toolsai.jupyter-keymap\",\"uuid\":\"9f6dc8db-620c-4844-b8c5-e74914f1be27\"},\"displayName\":\"Jupyter Keymap\"},{\"identifier\":{\"id\":\"ms-toolsai.jupyter-renderers\",\"uuid\":\"b15
@tuhulab
tuhulab / ComplexHeatmap.R
Last active September 5, 2022 06:44
Plot a complex heatmap
library(ComplexHeatmap)
count_matrix # if your data is called count_matrix
# Read data
se <- readRDS("data/se.rds")
count_matrix <- assay(se)
# Data transformation
count_matrix_log2 <- log2(count_matrix + 1)
@tuhulab
tuhulab / mergeLib.R
Created March 8, 2021 08:40
R function to merge libraries
counttable_merge_library_fun <- function(counttable_data = ...,
lib_to_merge_vector = ...){
lib_id <- counttable_data %>% colnames() %>% str_extract("lib\\d{1,}")
merged_counttable <- sapply(lib_to_merge_vector, function(one_lib_id_to_merge){
merged_counts <- counttable_data %>% select((lib_id == one_lib_id_to_merge) %>% which()) %>% rowSums()
merged_counts_df <- tibble(one_lib_id_to_merge = merged_counts)
return(merged_counts_df)
}) # The function to merge libs for counttable -----------------
# list tidy
MergedLib <- do.call(rbind.data.frame, merged_counttable) %>% t() %>% as.data.frame() %>% tibble()
@tuhulab
tuhulab / gene_cleaneR.R
Last active March 8, 2021 12:47
quick trick to clean pseudo genes
library(dplyr)
a_vector_of_genes <- c("AP005212.4", "Z98257.1", "U62317.4", "CLIC4P3", "PGLYRP2", "NEK4P1")
a_vector_of_cleaned_genes <- data.frame(a_vector_of_genes) %>% filter(!a_vector_of_genes %>% stringr::str_detect("\\d{1,}P$|\\d{1,}P\\d{1,}$|\\.|-AS\\d{1}|-DT")) %>% pull(a_vector_of_genes)
@tuhulab
tuhulab / clusteR.R
Last active September 30, 2020 10:40
Performing cluster analyis in R
# Cluster analysis in R
# inspired by Dima Gorenshteyn, DataCamp
## standardize data
df_st <- scale(df)
## Hierachical clustering
d <- dist(df)
hc <- hclust(d, "method") # method %in% c("complete", "average", "single")
c <- cutree(hc, h = the_height) # h: the height to cut the tree # assign cluster
@tuhulab
tuhulab / gist:6f57f70b6b1e6db0ef07d1dc3c8d94b1
Created August 28, 2020 08:24
Neg feature maniputation for Muyao
pos_n_max <- pos_data %>% pull(feature) %>% stringr::str_match("\\d{1,}") %>% max()
neg_feature_n <- neg_data %>% pull(feature) %>% stringr::str_match("\\d{1,}")
neg_data %>% mutate(feature = paste0("F", neg_feature_n + pos_n_max))
@tuhulab
tuhulab / EnrichR.R
Created August 7, 2020 06:05
How to run Enrichr from R
# First install R (https://www.r-project.org/) and RStudio(https://rstudio.com/)
# Install enrichR
install.packages("enrichR")
# Load enrichR
library(enrichR)
# Get your gene list, e.g. type by hand
Inflammatory_markers <- c("IL13","MMP12","IL22","NTRK1", "CCL17", "IL36A", "ICOS", "CCL18", "ALOX15", "CCL1", "CCR5", "IL13RA2", "IL19", "CCR7","CCL20", "CCR4","CCR2","CCL11","CCL22","CCR8","CCL19","CCL26","CCL3")