Skip to content

Instantly share code, notes, and snippets.

View pimentel's full-sized avatar

Harold Pimentel pimentel

View GitHub Profile
@pimentel
pimentel / covid_swe_since_2020_01_22.R
Last active May 4, 2020 04:00
Attempting to recreate M. Levitt Sweden COVID plot
# reference:
library('cowplot')
library('dplyr')
library('ggplot2')
library('lubridate')
data <- read.csv("https://opendata.ecdc.europa.eu/covid19/casedistribution/csv", na.strings = "", fileEncoding = "UTF-8-BOM")
swe = filter(data, countryterritoryCode == 'SWE')
@pimentel
pimentel / data.table_roll-nearest.R
Last active March 16, 2022 07:06
examples of rolling join in data.table
DT1 <- data.table(x = 1:5)
DT2 <- data.table(y = (1:5) + 0.01)
setkey(DT1, x)
setkey(DT2, y)
# the following does not maintain both columns
DT1[DT2, roll = 'nearest']
# x
# 1: 1
# 2: 2
@pimentel
pimentel / sleuth_DESeq2.R
Created March 18, 2016 18:47
very simple sleuth/DESeq2 comparison at transcript level
suppressPackageStartupMessages({
library('Biobase')
library('DESeq2')
library('sleuth')
})
base_dir <- "~/Downloads/cuffdiff2_data_kallisto_results"
sample_id <- dir(file.path(base_dir,"results"))
@pimentel
pimentel / removeCollaborator.js
Created December 31, 2015 21:21
Remove yourself as a collaborator from many github repositories
var GithubApi = require("github");
// you can install the required module using `npm install github`
var user = "myUsername";
var password = "myPassword";
function filterRepos(item) {
var lowerName = item.full_name.toLowerCase();
return item.owner.login !== 'berkeley-stat243' &&
@pimentel
pimentel / head.list.R
Last active June 27, 2018 03:09
Slightly more sane head() for lists in R
catDf <- data.frame(meow = rnorm(100), purr = rpois(100, 3))
aList <- list(aVector = 1:20, aDf = catDf, anotherList = list(1:200, 1:20))
# annoying as hell, right?
head(aList)
#' Return the first or last part of a list
#'
#' Returns the first or last part of a list. Instead of returning the first
#' n entries as the standard head() does, it attempts to call head()