Skip to content

Instantly share code, notes, and snippets.

View jokergoo's full-sized avatar
🚀

Zuguang Gu jokergoo

🚀
View GitHub Profile
@jokergoo
jokergoo / gridtext.R
Last active March 21, 2020 16:35
support gridtext in ComplexHeatmap
library(ComplexHeatmap)
set.seed(123)
mat = matrix(rnorm(100), 10)
rownames(mat) = letters[1:10]
ht = Heatmap(mat,
column_title = gt_render("Some <span style='color:blue'>blue text **in bold.**</span><br>And *italics text.*<br>And some <span style='font-size:18pt; color:black'>large</span> text.",
r = unit(2, "pt"),
padding = unit(c(2, 2, 2, 2), "pt")),
column_title_gp = gpar(box_fill = "orange"),
library(GenomicInteractions)
data(hic_example_data)
hic_example_data = as.data.frame(hic_example_data)
hic_example_data = hic_example_data[hic_example_data$seqnames1 == hic_example_data$seqnames2, ]
gr1 = hic_example_data[, c("seqnames1", "start1", "end1")]
colnames(gr1) = c("chr", "start", "end")
mat = matrix(0, nrow = 10, ncol = 27)
mat[2, c(1, 2, 3, 13, 14, 15, 17, 23, 25)] = 1
mat[3, c(1, 5, 6, 7, 9, 10, 11, 13, 15, 17, 19, 20, 21, 23, 24, 25)] = 1
mat[4, c(1, 5, 7, 9, 10, 11, 13, 14, 17, 19, 21, 24)] = 1
mat[5, c(1, 2, 3, 5, 6, 7, 9, 11, 13, 17, 19, 20, 23, 25)] = 1
mat[7, c(1, 3, 14, 25, 26, 27)] = 1
mat[8, c(1, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 27)] = 1
giggle_dir = "/icgc/dkfzlsdf/analysis/B080/guz/giggle_test/giggle"
giggle_data_dir = "/icgc/dkfzlsdf/analysis/hipo/hipo_016/analysis/WGBS_final_cohort/giggle_data"
temp_dir = "/icgc/dkfzlsdf/analysis/hipo/hipo_016/analysis/WGBS_final_cohort/temp"
library(GetoptLong)
build_giggle_index = function(gr_list, name = "anno") {
system(qq("mkdir @{giggle_data_dir}/@{name}"))
# write as bed files
for(nm in names(gr_list)) {
qqcat("writing @{nm}.bed\n")
#!c:/perl/bin/perl -w
use strict;
use LWP::Simple;
use CGI;
my $package = param("package")
if($package eq "ComplexHeatmap" or
$package eq "EnrichedHeatmap" or
Path of SRA files:
http://sra-download.ncbi.nlm.nih.gov/srapub/SRR\\d+
var unread = new Array();
var checked = new Array();
var from = new Array();
var subject = new Array();
var rows = new Array();
load_all = function() {
rows = document.getElementsByClassName("lvm")[0].lastChild.childNodes;
is_abs_unit <- function(x) UseMethod("is_abs_unit")
is_abs_unit.unit = function(x) {
unit = attr(x, "valid.unit")
if(unit %in% c(1:4, 7:24)) {
return(TRUE)
} else {
return(FALSE)
}
set_module = function(module) {
assign("__module__", module, envir = parent.frame())
}
load_module = function(file) {
e = new.env()
source(file, local = e, verbose = FALSE)
module = get("__module__", envir = e)
rm(e)
bedtools = function(cmd, envir = parent.frame()) {
gr = gsub("^.*@\\{(.*?)\\}.*$", "\\1", cmd)
gr = get(gr, envir = envir)
file = tempfile(fileext = ".bed")
write.table(gr, file = file, sep = "\t", quote = FALSE, row.names = FALSE, col.names = FALSE)
cmd = gsub("@\\{.*?\\}", file, cmd)
try(tb <- read.table(pipe(cmd), stringsAsFactors = FALSE))
file.remove(file)
return(tb)
}