Skip to content

Instantly share code, notes, and snippets.

View adomingues's full-sized avatar

A. Domingues adomingues

View GitHub Profile
@adomingues
adomingues / readBAM.R
Created January 3, 2019 09:13 — forked from SamBuckberry/readBAM.R
Import a bam file into R
# 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"
@adomingues
adomingues / gtf_transcript_length
Created May 17, 2018 19:27 — forked from sp00nman/gtf_transcript_length
Calculate transcript length of GTF file
# resource: http://seqanswers.com/forums/showthread.php?t=4914
# Calculate length for each transcript for a GTF file
awk -F"\t" '
$3=="exon"
{
ID=substr($9, length($9)-16, 15);
L[ID]+=$5-$4+1
}
END{
for(i in L)
@adomingues
adomingues / deseq2-analysis-template.R
Created December 19, 2017 11:25 — forked from stephenturner/deseq2-analysis-template.R
Template for analysis with DESeq2
## RNA-seq analysis with DESeq2
## Stephen Turner, @genetics_blog
# RNA-seq data from GSE52202
# http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=gse52202. All patients with
# ALS, 4 with C9 expansion ("exp"), 4 controls without expansion ("ctl")
# Import & pre-process ----------------------------------------------------
# Import data from featureCounts
@adomingues
adomingues / convert_tx_to_gene.R
Last active October 19, 2017 12:40 — forked from hussius/sleuth_commands.R
tximport functions
# A function (borrowed from the Sleuth documentation) for connecting Ensembl transcript names to common gene names
convert_tx_to_gene <- function(dat="drerio_gene_ensembl"){
mart <- biomaRt::useMart(
biomart = "ensembl",
dataset = dat
)
t2g <- biomaRt::getBM(
attributes = c("ensembl_transcript_id", "ensembl_gene_id", "external_gene_name"),
mart = mart
@adomingues
adomingues / hg19.rRNA.interval_list
Last active April 6, 2017 10:00 — forked from slowkow/hg19.rRNA.interval_list
Make a ribosomal RNA interval_list for Picard Tools CollectRnaSeqMetrics
@SQ SN:chrM LN:16571
@SQ SN:chr1 LN:249250621
@SQ SN:chr2 LN:243199373
@SQ SN:chr3 LN:198022430
@SQ SN:chr4 LN:191154276
@SQ SN:chr5 LN:180915260
@SQ SN:chr6 LN:171115067
@SQ SN:chr7 LN:159138663
@SQ SN:chr8 LN:146364022
@SQ SN:chr9 LN:141213431
@adomingues
adomingues / themes.R
Last active March 22, 2017 11:03 — forked from Pakillo/themes.R
ggplot_themes
### My favourite ggplot2 themes, always accessible ###
## just source this gist from any project ##
#####################################################################################
# Noam's default ggplot2 styling #####
# Source: https://github.com/noamross/noamtools/blob/master/R/theme_nr.R
theme_nr <-theme(text=element_text(family="Helvetica", size=14),
panel.grid.major.x=element_blank(),
@adomingues
adomingues / multiplot.r
Created March 16, 2017 14:59 — forked from tonglu/multiplot.r
multiplot for ggplot
# Multiple plot function
#
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
#
@adomingues
adomingues / iwanthue.R
Created June 20, 2016 06:40 — forked from johnbaums/iwanthue.R
Palettes of distinct colours, generated through kmeans clustering of LAB colour space
swatch <- function(x) {
# x: a vector of colours (hex, numeric, or string)
par(mai=c(0.2, max(strwidth(x, "inch") + 0.4, na.rm = TRUE), 0.2, 0.4))
barplot(rep(1, length(x)), col=rev(x), space = 0.1, axes=FALSE,
names.arg=rev(x), cex.names=0.8, horiz=T, las=1)
}
# Example:
# swatch(colours()[1:10])
# swatch(iwanthue(5))