Skip to content

Instantly share code, notes, and snippets.

View slavailn's full-sized avatar

slava ilnytskyy slavailn

View GitHub Profile
@slavailn
slavailn / edgeR_GLM_smallRNA.R
Created February 20, 2019 23:39
Edger GLM approach with 2 treatments over 3 time-points on small RNA tags
library(edgeR)
setwd(<dir>)
files <- list.files("/tag_counts/", full.names = T) # tab delimited file with sequenca tags and raw counts
files
d <- readDGE(files, columns = c(1,2))
counts <- d$counts
sampleFile <- <sampleFile>
sampleInfo <- read.table(sampleFile, sep = "\t", header = T, stringsAsFactors = F)
@slavailn
slavailn / get_bwa_mapping_stats.sh
Created January 17, 2019 21:49
Get BWA mapping stats (mapped, unmapped reads, number of reads with MAPQ20)
#! /bin/bash
echo -e "Samplename\tTotal_reads\tMapped_reads\tUnmapped_reads\tMAPQ20_reads\tPercent_mapped\tPercent_MAPQ20_reads"
for file in ./*bam
do
filename=`basename $file`
samplename=${filename%.bam}
total_reads=`samtools view -c $file`
mapped_reads=`samtools view -c -F 4 $file`
@slavailn
slavailn / Process_ChIP-seq_peaks.R
Created January 14, 2019 22:20
Process ChIP-seq peaks, based on multiple Bioconductor packages, but centered on ChipSeeker and ClusterProfiler
library(GenomicRanges)
library(ChIPpeakAnno)
library(genomation)
library(biomaRt)
library(ChIPseeker)
library(org.Mm.eg.db)
library(ReactomePA)
library(clusterProfiler)
setwd("<project_dir>")
@slavailn
slavailn / ChipSeeker_vignette.R
Created January 10, 2019 23:00
Going through ChIPseeker vignette, will modify as necessary for the actual analysis
library(ChIPseeker)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(clusterProfiler)
# Gene data from UCSC hg19
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
# Peak file in bed format (these are MACS files)
files <- getSampleFiles()
files
@slavailn
slavailn / GenomicDataCommons_rnaseq.R
Created December 21, 2018 22:13
GenomicDataCommons vignette examples and how to download RNA-seq data from GDC
library(GenomicDataCommons)
library(DESeq2)
library(ggplot2)
setwd("~/Projects/MYT1L_TCGA_project/")
###############################################################################################
# Vignette examples
# Check connectivity and functionality
GenomicDataCommons::status()
@slavailn
slavailn / plotDMR_ggbio.R
Created December 12, 2018 01:09
plot DMR using ggbio (ggplot type graphics, separate pane for every sample with a bar graph for methylation percent)
library(GenomicRanges)
library(ggbio)
library(ChIPpeakAnno)
gr <- GRanges(seqnames = "NC_035082.1", IRanges(55355800, 55355870), strand = "*")
# Get methylation percents from metilene input and convert to GRanges object
input <- read.table("metilene_Control_Treated.input", sep = "\t", header = T, stringsAsFactors = F)
names(input)[1] <- "chr"
names(input)[2] <- "start"
@slavailn
slavailn / ggbio_examples.R
Created December 11, 2018 23:28
Going through code examples in ggbio
library(GenomicRanges)
library(ggbio)
library(IRanges)
set.seed(1)
N <- 1000
gr <- GRanges(seqnames =
sample(c("chr1", "chr2", "chr3"),
size = N, replace = TRUE),
IRanges(
@slavailn
slavailn / show_genomic_tracks.R
Created December 10, 2018 22:29
Display genomic tracks - ggbio, sushi
library(Rsamtools)
library(rtracklayer)
library(Sushi)
# Draw raw alignment track for each bam file
setwd("~/Projects/Wiseman_Trout_RRBS/")
list.files("bam")
# Create TxDb object from GFF
chromInfo <- read.table("~/GENOMES/Rainbow_trout/GCF_002163495.1_Omyk_1.0_genomic.fa.fai", header = F,
@slavailn
slavailn / forge_BSgenome.R
Created December 7, 2018 00:41
forge BSgenome package for non model organism (Rainbow trout as an example)
library(BSgenome)
## Create seed file with the following lines
# Package: BSgenome.Omykiss.NCBI.Omyk1
# Title: Full genome sequences for Oncorhynchus mykiss (NCBI RefSeq version Omyk_1.0)
# Description: Full genome sequences for Oncorhynchus mykiss (Rainbow trout) as provided by MCBI (Omyk_1.0, 2017-6-2) and stored in Biostrings objects.
# Version: 1.0
# organism: Oncorhynchus mykiss
# common_name: Rainbow trout
# provider: NCBI
@slavailn
slavailn / txdb_non_model.R
Created December 6, 2018 20:45
Create TxDb for non-model organism (example: Rainbow Trout)
library(GenomicFeatures)
# Get chromInfo file
chromInfo <- read.table("~/GENOMES/Rainbow_trout/GCF_002163495.1_Omyk_1.0_genomic.fa.fai", header = F,
stringsAsFactors = F, sep = "\t")
head(chromInfo)
chromInfo <- chromInfo[,c(1,2)]
names(chromInfo) <- c("chrom", "length")
is_circular <- rep(FALSE, dim(chromInfo)[1])