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
ggColocManhattanSingle <- function( | |
summ.1, chr = "CHR", bp = "BP", p = "P", snp = "SNP", | |
summ.1.name = expression(paste("", -log[10](P))), | |
logp = TRUE, size = 2, lead.snp = NULL, r2 = NULL, ... | |
) { | |
if (!is.null(summ.1[[snp]])) { | |
d1 <- data.frame(CHR = summ.1[[chr]], BP = summ.1[[bp]], P = summ.1[[p]], SNP = summ.1[[snp]]) | |
} else { | |
d1 <- data.frame(CHR = summ.1[[chr]], BP = summ.1[[bp]], P = summ.1[[p]]) |
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
## Run GLIMPSE on scATAC bam files | |
import pandas as pd | |
import os | |
smp = os.listdir("/project/yangili1/zpmu/covid19/data/cellranger_out21") | |
SNPDIR = "/project/yangili1/zpmu/covid19/data/hornet_snp" | |
chrm = sorted([str(x) for x in range(1, 23)]) |
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
ggQQplot <- function(pList, colVec = c("black", "orange", "red", "purple"), | |
legendLabel = NULL, title = "", openRange = F, sampling = 1) { | |
if (is.null(legendLabel)) { | |
legendLabel = colVec | |
} | |
if (length(pList) > length(colVec)) { | |
stop("pList needs to be shorter than colVec!!!") | |
} |
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
getFDR <- function(Stat, Stat0) { | |
m <- length(Stat) | |
n <- length(Stat0) | |
v <- c(rep(T, m), rep(F, n)) | |
v <- v[order(c(Stat, Stat0), decreasing = T)] | |
vSumT <- (m - cumsum(v == T)[v == T] + 1) / m | |
vSumF <- (n - cumsum(v == F)[v == T]) / n | |
fdr <- cummin(pmin(1, vSumF / vSumT)) | |
fdr <- fdr[rank(-Stat)] | |
return(fdr) |
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
disjoinGr <- function(df, chr = "CHR", bp = "BP", pval = "Pval", snp = "SNP", size = 5e5) { | |
inGr <- GRanges(df[[chr]], IRanges(df[[bp]] - size, df[[bp]] + size - 1), | |
SNPID = df[[snp]], BP = df[[bp]], Pval = df[[pval]]) | |
disjointGr <- disjoin(inGr) | |
ov <- findOverlaps(resize(inGr, 1, "center"), disjointGr) | |
hitGr <- disjointGr[subjectHits(ov)] | |
ovGr <- setdiff(disjointGr, hitGr) | |
firstHalf <- resize(ovGr, width(ovGr) / 2 - 1, "start") | |
secondHalf <- resize(ovGr, width(ovGr) / 2, "end") |