Skip to content

Instantly share code, notes, and snippets.

View jokergoo's full-sized avatar
🚀

Zuguang Gu jokergoo

🚀
View GitHub Profile
library(circlize)
par(mfrow = c(2, 2))
circos.initialize(c("a"), xlim = c(0, 1))
circos.track(ylim = c(0, 1), track.height = 0.7, bg.border = NA,
panel.fun = function(x, y) {
circos.lines(CELL_META$cell.xlim, rep(CELL_META$cell.ylim[1], 2), col = "#CCCCCC")
circos.lines(CELL_META$cell.xlim, rep(CELL_META$cell.ylim[2], 2), col = "#CCCCCC")
x0 = runif(1000)
gsub_eval = function(pattern, replacement, x, ignore.case = FALSE, perl = FALSE,
fixed = FALSE, useBytes = FALSE, envir = parent.frame()) {
txt = gsub(
pattern = pattern,
replacement = replacement,
x = x,
ignore.case = ignore.case,
perl = perl,
fixed = fixed,
useBytes = useBytes
@jokergoo
jokergoo / jaccard_heatmap.R
Last active October 3, 2022 11:53
jaccard_heatmap.R
library(GenomicRanges)
library(HilbertCurve)
library(ComplexHeatmap)
library(InteractiveComplexHeatmap)
library(GetoptLong)
file_list = c(
"IDH_DMV" = "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE121nnn/GSE121721/suppl/GSE121721_IDH_methylation_features_DMV.bed.gz",
"IDH_LMR" = "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE121nnn/GSE121721/suppl/GSE121721_IDH_methylation_features_LMR.bed.gz",
"IDH_PMD" = "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE121nnn/GSE121721/suppl/GSE121721_IDH_methylation_features_PMD.bed.gz",
@jokergoo
jokergoo / heatmap_3d.R
Last active October 3, 2022 11:54
a simple 3D heatmap
rect3D = function(x, y, w, h, l, theta = 60, default.units = "npc", fill = "white", col = "black") {
if(!is.unit(x)) x = unit(x, default.units)
if(!is.unit(y)) y = unit(y, default.units)
if(!is.unit(w)) w = unit(w, default.units)
if(!is.unit(h)) h = unit(h, default.units)
if(!is.unit(l)) l = unit(l, default.units)
x1 = x - w*0.5
x2 = x + w*0.5
m = matrix(rnorm(100), 10)
rownames(m) = paste0("row", 1:10)
colnames(m) = paste0("column", 1:10)
ht = draw(Heatmap(m, name = "mat"))
highlight_row = function(which, padding = unit(1, "mm"), gp = gpar()) {
row_order = row_order(ht)
i = which(row_order == which)
nr = length(row_order)
load(system.file("extdata", "doodle.RData", package = "circlize"))
img = do.call(cbind, lapply(img_list, function(x) as.matrix(as.raster(x)[1:106, 1:150])))
img = as.raster(img)
library(spiralize)
spiral_initialize(scale = "curve", start = 180, end = 360*3)
spiral_track(background = FALSE)
spiral_raster(0.5, 0.5, img, facing = "curved_inside")
library(COVID19)
library(ComplexHeatmap)
library(circlize)
library(spiralize)
library(RColorBrewer)
spiral_initialize_by_time(xlim = c("2020-01-02", "2022-01-07"),
vp_param = list(x = unit(0, "npc"), width = unit(0.9, "snpc"), height = unit(0.9, "snpc"), just = "left"))
library(COVID19)
library(ComplexHeatmap)
library(circlize)
library(spiralize)
library(RColorBrewer)
library(shiny)
library(lubridate)
env = new.env()
library(GetoptLong)
library(shiny)
library(rvest)
library(DT)
html = read_html("https://cran.r-project.org/web/checks/check_summary_by_package.html")
html %>% html_element("table") %>% html_table(header = FALSE) -> tb
tb = as.data.frame(tb)
library(matrixStats)
library(genefilter)
gene_level = function(mat, condition, method = "tvalue", transform = "none",
binarize = function(x) x) {
le = levels(condition)
l_group1 = condition == le[1]
l_group2 = !l_group1