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
| tpManhattanSingle <- function( | |
| summ.1, chr = "CHR", bp = "BP", p = "P", snp = "SNP", | |
| summ.1.name = "$-log[10](P)$", plot.label = NULL, | |
| logp = TRUE, size = 2, lead.snp = NULL, r2 = NULL, | |
| plot.width = 100, plot.height = 50, ... | |
| ) { | |
| 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 { |
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
| snippet script_header | |
| ################################################################################ | |
| ## Script Purpose: ${0} | |
| ## Author:Zepeng Mu ([email protected]) | |
| ## Date: `r format(Sys.time(), "%a, %b %e %Y")` | |
| ################################################################################ | |
| snippet h1 | |
| # ${0:Header1} ---- | |
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"), | |
| sizeVec = rep(0.3, length(colVec)), | |
| legendLabel = NULL, title = "", openRange = F, sampling = 1, | |
| signList = NULL) { | |
| if (is.null(legendLabel)) { | |
| legendLabel = colVec | |
| } | |
| if (length(pList) > length(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") |