Skip to content

Instantly share code, notes, and snippets.

@mlist
mlist / plot_sra_stat.R
Created April 2, 2023 10:31
Plot the amount of sequencing data from SRA
library(ggplot2)
library(tidyverse)
library(readr)
sra_stat <- read_csv("https://www.ncbi.nlm.nih.gov/Traces/sra/sra_stat.cgi")
sra_stat$date <- as.Date(sra_stat$date, format = "%m/%d/%Y")
ggplot(sra_stat, aes(x = date, group = 1)) +
geom_area(aes(y = bases / 10^15), fill = "orange", alpha = 0.8) +
geom_area(aes(y = bytes / 10^15), fill = "blue", alpha = 0.8) +
labs(title = "Amount of Sequencing Data in SRA",
@mlist
mlist / convert_gddoc_to_pdf.sh
Created September 26, 2019 14:47
bash script to batch convert all insync gddoc files in a folder to PDF
#!/bin/bash
#convert all gddoc documents to pdf
#needs jq: https://stedolan.github.io/jq/download/
shopt -s nullglob
for g in *.gddoc
do
url=$(jq -c '.url' $g)
url="${url%/edit?usp=drivesdk\"}"
url="${url#\"}"
@mlist
mlist / read_gmt.r
Created August 22, 2017 08:49
function for reading gmt files as data frames with 1st column gene set id, 2nd column gene id.
library(foreach)
library(stringr)
library(biomaRt)
read_gmt <- function(gmt_file){
conn <- file(gmt_file,open="r")
all_lines <-readLines(conn)
result <- foreach(line = str_split(all_lines, "\t"), .combine = bind_rows) %do% {
data_frame(id = line[1], gene_id = line[-c(1,2)])
@mlist
mlist / ensembl_regulatory_build_to_tab.r
Last active June 2, 2021 15:14
converting ENSEMBL regulatory build GFF file to a regular tab delimited file
#obtained from ftp://ftp.ensembl.org/pub/grch37/release-87/regulation/homo_sapiens/homo_sapiens.GRCh37.Regulatory_Build.regulatory_features.20161117.gff.gz
#date: 12/01/2017
library(stringr)
library(tidyr)
homo_sapiens.GRCh37.Regulatory_Build.regulatory_features.20161117 <- read.delim("/local/home/mlist/Projects/homo_sapiens.GRCh37.Regulatory_Build.regulatory_features.20161117.gff", header=FALSE)
ensembl_reg_hg19 <- tidyr::separate(homo_sapiens.GRCh37.Regulatory_Build.regulatory_features.20161117, col = V9, into = c("ID", "bound_end", "bound_start", "description", "feature_type"), sep = ";")
apply(ensembl_reg_hg19, 2, function(x) str_replace_all(x, pattern = ".*=", ""))
ensembl_reg_hg19_tidy <- apply(ensembl_reg_hg19, 2, function(x) str_replace_all(x, pattern = ".*=", ""))
@mlist
mlist / blueprint_gene_exprs_fpkm.r
Created October 20, 2016 11:23
Download all BLUEPRINT gene expression data and format as numeric matrix
# Load dependencies
# install DeepBlueR from bioconductor
# http://bioconductor.org/packages/release/bioc/html/DeepBlueR.html
library(DeepBlueR)
library(dplyr)
library(tidyr)
# List all BLUEPRINT samples
blueprint_samples <- deepblue_list_samples(
extra_metadata = list("source" = "BLUEPRINT Epigenome"))
@mlist
mlist / batch_effects_in_deep.r
Last active January 16, 2017 15:00
Demo script for batch effect analysis of DEEP data using DeepBlueR
# authentication, register for DeepBlue, log in, open your account info,
# copy and paste user key here
auth_key <- "xxxxxxxxxx"
#dependencies
library(foreach)
library(matrixStats)
library(DeepBlueR)
library(stringr)
library(corrplot)
@mlist
mlist / install_ms_r_open.sh
Last active August 24, 2016 03:12
How to get Microsoft R Open 3.2.3 to run on Debian Jessie
### PLAIN INSTALLATION ###
#Download the installer for Microsoft R Open built for Ubuntu 15
wget https://mran.revolutionanalytics.com/install/mro/3.2.3/MRO-3.2.3-Ubuntu-15.4.x86_64.deb
#Install package ignoring the missing libjpeg dependency
sudo dpkg -i --ignore-depends libjpeg8 MRO-3.2.3-Ubuntu-15.4.x86_64.deb
#At this point you can already use MRO but plotting won't work!
@mlist
mlist / convertToRnBeadSet.r
Created February 11, 2016 10:17
Convert RnBeadRawSet to RnBeadSet class. Can be used with as(some.rnb.raw.set, "RnBeadSet").
setAs("RnBeadSet", "RnBeadRawSet", function(from){
new(Class = RnBeadSet,
pval.sites = [email protected],
pval.regions = [email protected],
qc = from@qc,
pheno = from@pheno,
sites = from@sites,
meth.sites = [email protected],
covg.sites = [email protected],
regions = from@regions,
@mlist
mlist / delete_all_images
Created January 14, 2016 13:27
Deletes all docker images...
sudo docker images -a | awk 'NR >= 2 {printf "%s ",$3}' | xargs sudo docker rmi -f
@mlist
mlist / RESTful_KeyPathwayMiner.r
Last active April 1, 2020 08:08
This R script contains usage examples for accessing the KeyPathwayMinerWeb RESTful API defined at http://tomcat.compbio.sdu.dk/keypathwayminer/documentation/rest/Usage examples depend on methods defined in RESTful_KeyPathwayMiner.r
### R functions to consume the KeyPathwayMinerWeb RESTful API ###
### Authors: Markus List and Martin Dissing-Hansen ###
# Package dependencies. Make sure those are installed
library(RCurl)
library(rjson)
library(foreach)
# Helper method for base64 encoding. Needed to transfer network and dataset files #
base64EncFile <- function(fileName){