This file contains 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
#' Get the signal from bigwig file for defined regions. | |
#' | |
#' @param bigwig Path to a bigwig file. Also accpets http paths. | |
#' @param gr A genomic ranges object of regions to obtain signal. All ranges should be the same width. | |
#' @param range The distance from the centre of gr to flank. Default=100. | |
#' @param log Logical. Is the signal in the bigwig file in log space? Default=FALSE. | |
#' If log = TRUE, the scores in the bigwig file are transformed by e^scores. | |
#' @return A numeric vector of aggregate signal if aggregate = TRUE, which is the default. | |
#' If aggregate = FALSE a data.frame of signal of all regions is returned. | |
#' @export |
This file contains 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
library(magrittr) | |
library(GenomicRanges) | |
library(BSgenome.Mmusculus.UCSC.mm10) | |
library(rtracklayer) | |
library(reshape2) | |
library(ggplot2) | |
library(dplyr) | |
library(JASPAR2016) | |
library(TFBSTools) | |
library(stringr) |
This file contains 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
library(magrittr) | |
library(GenomicRanges) | |
library(BSgenome.Mmusculus.UCSC.mm10) | |
library(rtracklayer) | |
library(reshape2) | |
library(ggplot2) | |
library(dplyr) | |
library(JASPAR2016) | |
library(TFBSTools) | |
library(stringr) |
This file contains 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
### Get Tn5 bias track for regions | |
bias_bigwig <- "~/Desktop/mm10_bias_chr19.Scores.bigwig" | |
atac_regions <- "~/polo_iPSC/ATACseq/processed_data/atac_peaks/atac_all_peaks_union.bed" | |
atac_bam <- "~/Desktop/atac_iPSC_combined_replicates_chr19.bam" | |
ctcf <- read.table("~/R_packages/RunATAC/inst/exdata/ctcf.pwm") %>% as.matrix() | |
#' Read BED formatted file to GRanges object | |
#' | |
#' @param bed_file Path Path to BED formatted file. |
This file contains 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
library(data.table) | |
library(R.utils) | |
aggregateStrandsCG <- function(CGmap){ | |
# Do not output scientific notation | |
options(scipen=999) | |
# Create the temp directory for uncompressed CGmap file | |
tmpFile <- tempfile(tmpdir = tempdir(), fileext = ".CGmap.tmp") |
This file contains 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
# See examples at http://sambuckberry.github.io/2015/07/15/quickCorPlots/ | |
plotAnnotatedScatter <- function(x, y, pointCol=rgb(0,0,0,0.7), | |
legendPos="topleft", legendCex=1, ... ){ | |
# Generate a linear model summary | |
fit <- lm(y ~ x) | |
fitSum <- summary(fit) | |
r2 <- fitSum$r.squared | |
pVal <- fitSum$coefficients[2,4] | |
This file contains 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
#source("http://bioconductor.org/biocLite.R") | |
#biocLite(c("rtracklayer", "Rsamtools", "GenomicRanges")) | |
library(rtracklayer) | |
library(Rsamtools) | |
library(GenomicRanges) | |
library(GenomicAlignments) | |
#' SummarizeOverlapsByGene | |
#' |
This file contains 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
## Write a bash script for looping through the bam files | |
#! /bin/bash | |
for i in *accepted_hits.bam | |
do | |
samtools index ${i} | |
done | |
## Save this files as indexBamFiles.sh |
This file contains 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
# install the Rsamtools package if necessary | |
source("http://bioconductor.org/biocLite.R") | |
biocLite("Rsamtools") | |
# load the library | |
library(Rsamtools) | |
# specify the bam file you want to import | |
bamFile <- "test.bam" |