Skip to content

Instantly share code, notes, and snippets.

View crazyhottommy's full-sized avatar
🎯
Focusing

Ming Tang crazyhottommy

🎯
Focusing
View GitHub Profile

load libraries

#install.packages("tidyverse")
#install.packages("Seurat")
# here package is to get rid of absolute path
# see details https://github.com/jennybc/here_here
#install.packages("here")
# interact with file systems https://github.com/r-lib/fs
@crazyhottommy
crazyhottommy / get_mouse_gene_length.md
Created October 22, 2018 03:11
get mouse gene length
# stop using biocLite https://twitter.com/strnr/status/1022451016736927745?lang=en
# more details https://cran.r-project.org/web/packages/BiocManager/vignettes/BiocManager.html
# require R>=3.5.0, if you have a lower version of R. you may still use biocLite to install 
# bioconductor packages

install.packages("BiocManager")
BiocManager::install("TxDb.Mmusculus.UCSC.mm9.knownGene")
@crazyhottommy
crazyhottommy / merge_feature_counts_table.md
Last active September 28, 2018 00:19
collate RNAseq feature counts table

R solution

library(purrr)
library(tidyverse)
f_files<- list.files("results/superEnhancer/rna_expression/MSTC", pattern = "featureCount.txt", full.names = T)

read_in_feature_counts<- function(file){
        cnt<- read_tsv(file, col_names =T, comment = "#")
        cnt<- cnt %>% dplyr::select(-Chr, -Start, -End, -Strand, -Length)
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {

When call chromHMM with a bin size of say 1000 bp, if the consecutive bins are of the same state, it will be merged.

I want to tile the segment file before merging. https://support.bioconductor.org/p/102775/#102777

library(GenomicRanges)
library(rtracklayer)
chromHMM_seg&lt;- import("data/chromHMM/SKCM-M852-P008_18_segments.bed", format = "BED")
#API created by @apfejes (Anthony Fejes) on top of my half-cooked script
#python ebi_url_from_srr.py --file srr_list.txt | xargs -I {} wget {}
import argparse
def prepareURL(srr_name, prefix="ftp://ftp.sra.ebi.ac.uk/vol1/fastq/"):
dir_1=srr_name[:6]
dir_2=""
url=""
num_digits=sum(s.isdigit() for s in srr_name)
if(num_digits == 6):