This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script allows to sell all your stocks on RobinHood at once using the RobinHood API. | |
# Only use if you understand what it does! | |
# install.packages("RobinHood") | |
library(RobinHood) | |
my_username <- "username" # replace with your username (should not contain any R special characters) | |
my_password <- "password" # replace with your password (should not contain any R special characters) | |
# Two-factor authentication needs to be turned off in order to connect using your password. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script illustrates how to add one label per stack in a stacked bar chart using ggplot in R. | |
# In this case, labels indicate the sum of values represented in each bar stack. | |
# The idea is to create as many labels as bars, but assign text to only one label per stack, then plot labels according to stack height. | |
# Data | |
df <- data.frame(stack=factor(rep(c("A", "B", "C"), each=3)), cat=factor(rep(c("X", "Y", "Z"), times=3)), val=1:9) | |
# Compute sum | |
totals <- as.vector(by(df$val, df$stack, sum)) | |
# Calculate label position | |
pos <- rep(totals + 1, each=3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This snippet illustrates how to query David from R, using the RDAVIDWebService package. | |
# Load RDAVIDWebService. | |
library("RDAVIDWebService") | |
# Create a DAVIDWebService object connected to David, using your registration email. | |
# To register, go to: http://david.abcc.ncifcrf.gov/content.jsp?file=WS.html. | |
david <- DAVIDWebService$new(email='[email protected]') | |
# Define foreground and background gene lists. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This snippet queries BioMart to find mRNA Refseq Ids associated with mouse gene symbols. | |
# Load biomaRt. | |
library(biomaRt) | |
# Get vector of gene symbols from a table loaded in R. | |
genes <- mytable$Gene | |
# Choose BioMart database and dataset. | |
mart <- useMart("ensembl", dataset="mmusculus_gene_ensembl") | |
# Specify filter used to read input values. | |
# A list of possible filters can be retrieved using listFilters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Wrapper to run a command on all files from a set of directories, and output to directories with matching names. | |
# Parameters need to be edited according to your data structure. | |
# The parameters here assume a project directory containing: | |
# - a "src" directory, from which are run this script and the executable used in the command. | |
# - a "data" directory, containing input directories that can be called using regular expressions. The input directories are named with an underscore-separated suffix indicating file format. | |
# - a "munge" directory, where output directories will be created with names matching those of the input directories, using a different underscore-separated suffix to indicate the output file format. | |
src_path=../src # Directory of the executable used in command -- edit with yours. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Description: This script converts a 3 columns tabular format, where columns are chr, start, value, to bedGraph format. Input file may be compressed as .gz. | |
# Coordinates in both input and bedGraph output are assumed to be 0-based (http://genome.ucsc.edu/goldenPath/help/bedgraph.html). | |
# Usage: tab3col_to_bedgraph.pl --tab input.tsv --bedgraph output.bedgraph | |
# --tab : specify input file in 3 columns tabular format, where columns are chr, start, value. | |
# --bedgraph : specify output file in bedgraph format. | |
# Credits: This script was written by Sebastien Vigneau ([email protected]) in Alexander Gimelbrant lab (Dana-Farber Cancer Institute). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Description: This script converts bedGraph to fixedStep wig format with defined step size. Input file may be compressed as .gz. | |
# Coordinates in bedGraph input are assumed to be 0-based (http://genome.ucsc.edu/goldenPath/help/bedgraph.html). | |
# Coordinates in wig output are 1-based (http://genome.ucsc.edu/goldenPath/help/wiggle.html). | |
# Usage: bedgraph_to_wig.pl --bedgraph input.bedgraph --wig output.wig --step step_size [--compact] | |
# --bedgraph : specify input file in bedGraph format. | |
# --wig : specify output file in fixedStep format. | |
# --step : specify step size. Note that span is set to be identical to step. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Function ## | |
# Function to merge dataframes, appending the original dataframe name to the corresponding columns | |
mergeDeluxe <- function (tomerge, by, all=T, pos="after", sep="_") { | |
# tomerge: list of dataframes | |
# by: name of column to use as a join to merge dataframes | |
# all: whether to keep non-matching lines, as defined in R base "merge" function | |
# pos: if "after", the dataframe name is appended as a suffix; if "before", it is appended as a prefix | |
# sep: separator to use when appending dataframe name | |