Skip to content

Instantly share code, notes, and snippets.

View BrunoGrandePhD's full-sized avatar

Bruno Grande BrunoGrandePhD

View GitHub Profile
@BrunoGrandePhD
BrunoGrandePhD / multi-gather.md
Last active July 20, 2018 01:29
Gather (melt) on multiple columns at once
library(data.table)
library(tidyverse)

anscombe

#>    x1 x2 x3 x4    y1   y2    y3    y4
#> 1  10 10 10  8  8.04 9.14  7.46  6.58
#> 2   8  8  8  8  6.95 8.14  6.77  5.76
#> 3  13 13 13  8  7.58 8.74 12.74  7.71
<html>
<head>
<title>Unix Lab Web Page Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="Bioinformatics, Fiona Brinkman, course">
<meta name="description" content="This is a template file to help you learn about HTML.">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><b><font size="+2" color="#0000FF">
gender eat_out weight
F 0 110
F 0 114
F 0 115
F 0 110
F 0 125
F 0 140
F 0 130
F 0 145
F 0 158
@BrunoGrandePhD
BrunoGrandePhD / Dockerfile
Created January 31, 2017 02:01
"Sentiment Analysis for Amazon Product Reviews" by Apala Guha
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y vim wget git htop tmux
RUN apt-get install -y openssh-client default-jre default-jdk
RUN apt-get install -y python2.7
RUN ln -s /usr/bin/python2.7 /usr/bin/python
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
RUN pip2.7 install numpy
RUN pip2.7 install pandas
@BrunoGrandePhD
BrunoGrandePhD / remove-big-file.sh
Created December 15, 2016 01:16
Remove a large committed file from your Git repository.
# The commands below are a guide to remove a large file that has been
# accidentally committed to a Git repository's history. If the file is
# larger than 100 MB, GitHub will prevent you from pushing your latest
# commits. The annotated steps below should help you remove the large
# file from your commit history, even if you've made new commit since.
# Some Git users advise against rebasing. You can safely use it here
# because you haven't published your changes yet.
# So, you first need to rebase your current branch onto the point that
@BrunoGrandePhD
BrunoGrandePhD / ggplot2_workshop.R
Created October 26, 2016 00:03
R script capturing what was covered in the SciProg.ca workshop on ggplot2 (https://github.com/sciprog-sfu/sciprog-sfu.github.io/issues/143)
## GGplot2 workshop Sciprog October 24 2016
# Author: Michelle Jones
library(ggplot2)
#install the packages for the workshop
#install.packages(c("tidyverse","ggthemes","cowplot"))
#install.packages("gapminder")
#Load packages
library(tidyverse)
library(ggthemes)
git branch new-master # Assumption: HEAD is pointing to the new commits
git checkout master
git branch before-revert
git revert --no-edit commit_X..master # Revert the commits you want to discard
git rebase -i before-revert # Optional: squash all commits except top one to create one revert commit
git checkout new-master
git rebase master
git checkout master
git merge new-master
git branch -D new-master before-revert
@BrunoGrandePhD
BrunoGrandePhD / calc_exon_cov.sh
Last active June 22, 2016 18:13
Command for calculating average coverage for genes in a targeted sequencing experiment
# Input:
# - exons.bed: Exons BED file with the fourth column containing the gene name for gene coverage summarizing
# - sample.bam: BAM file using the same genome build (aka chromosome names and coordinate system) as exons.bed
# Output:
# - Tab-delimited file with two columns: gene name and average coverage
samtools bedcov exons.bed sample.bam \
| awk ' \
BEGIN { \
FS=OFS="\t"} \
@BrunoGrandePhD
BrunoGrandePhD / fixpdf.sh
Created June 19, 2016 23:53
Sometimes, the font is messed up on a printed version of a PDF file. It seems that this may be caused by the missing embedded fonts in the PDF file. The following shell function simplifies the process.
# Ensure that fonts are embedded in a PDF file for correct printing
# Credit: http://stackoverflow.com/a/4234150
function fixpdf {
# Print usage is no arguments are given
if [ "$#" -eq 0 ]; then
echo "Usage: fixpdf PDF_FILE [PDF_FILE ...]"
fi
# Check if ghostscript is installed
if ! type gs >/dev/null 2>&1; then
echo 'Error: ghostscript is either not installed or not in your PATH.'
@BrunoGrandePhD
BrunoGrandePhD / icgc_to_maf.R
Created June 16, 2016 23:14
A simple R script to convert an ICGC simple mutations file into the TCGA MAF format for re-annotation with maf2maf (see vcf2maf)
suppressPackageStartupMessages({
library(readr)
library(dplyr)
})
maf_cols <- c(
"Hugo_Symbol","Entrez_Gene_Id","Center","NCBI_Build","Chromosome","Start_Position",
"End_Position","Strand","Variant_Classification","Variant_Type","Reference_Allele",
"Tumor_Seq_Allele1","Tumor_Seq_Allele2","dbSNP_RS","dbSNP_Val_Status","Tumor_Sample_Barcode",
"Matched_Norm_Sample_Barcode","Match_Norm_Seq_Allele1","Match_Norm_Seq_Allele2",