Skip to content

Instantly share code, notes, and snippets.

View sa-lee's full-sized avatar
🤠

Stuart Lee sa-lee

🤠
View GitHub Profile
@coolbutuseless
coolbutuseless / gganimate-sprites.R
Created August 13, 2018 13:07
gganimate sprites
library(tidyverse)
library(raster)
library(gganimate)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Not going to directly link in to script to avoid hitting server
# https://www.spriters-resource.com/resources/sheets/12/12593.png
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sprite_sheet <- png::readPNG("12593.png")
@jxtx
jxtx / bioc2018.md
Last active August 22, 2018 14:30
#bioC 2018 Conference Notes
@mikelove
mikelove / rawcounts.R
Created October 24, 2017 01:18
PCA on raw counts
# what dominates PC1: 100 features with 10x fold change or 1 feature with 2x fold change?
mat <- rbind(matrix(rpois(8*100,rep(c(10,100),each=4)),ncol=8,byrow=TRUE),
rpois(8,rep(c(1000,1000,2000,2000),2)))
plot(prcomp(t(mat))$x[,1])
@mikelove
mikelove / accession2url.R
Created June 16, 2016 18:33
ENA accession to URL
accession2url <- function(x) {
prefix <- "ftp://ftp.sra.ebi.ac.uk/vol1/fastq"
dir1 <- paste0("/",substr(x,1,6))
dir2 <- ifelse(nchar(x) == 9, "",
ifelse(nchar(x) == 10, paste0("/00",substr(x,10,10)),
ifelse(nchar(x) == 11, paste0("/0",substr(x,10,11)),
paste0("/",substr(x,10,12)))))
paste0(prefix,dir1,dir2,"/",x)
}
@mikelove
mikelove / tsne.R
Last active April 6, 2024 01:11
Exploring behavior of t-SNE on linear data
n <- 200
m <- 40
set.seed(1)
x <- runif(n, -1, 1)
library(rafalib)
bigpar(2,2,mar=c(3,3,3,1))
library(RColorBrewer)
cols <- brewer.pal(11, "Spectral")[as.integer(cut(x, 11))]
plot(x, rep(0,n), ylim=c(-1,1), yaxt="n", xlab="", ylab="",
col=cols, pch=20, main="underlying data")
@bishboria
bishboria / springer-free-maths-books.md
Last active June 8, 2024 06:39
Springer made a bunch of books available for free, these were the direct links
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@nickloewen
nickloewen / bret_victor-reading_list.md
Last active July 12, 2024 17:54
Bret Victor’s Reading List

This is a plain-text version of Bret Victor’s reading list. It was requested by hf on Hacker News.


Highly recommended things!

This is my five-star list. These are my favorite things in all the world.

A few of these works have had an extraordinary effect on my life or way of thinking. They get a sixth star. ★

@wch
wch / server.r
Last active September 8, 2023 20:25
Shiny example: dynamic input fields
data_sets <- c("mtcars", "morley", "rock")
shinyServer(function(input, output) {
# Drop-down selection box for which data set
output$choose_dataset <- renderUI({
selectInput("dataset", "Data set", as.list(data_sets))
})
# Check boxes
@dsparks
dsparks / Making k-folds.R
Created September 11, 2012 01:55
Random, equally-sized partitions
# Randomly allocating observations into groups, for, e.g. cross-validation
kk <- 10 # Number of partitions, as in "kk-fold cross-validation."
# Here is a data.frame full of good data:
nn <- 1003
myData <- data.frame(matrix(rnorm(nn * 3), ncol = 3))
colnames(myData) <- LETTERS[1:3]
# This does not work:
whichK <- sample(LETTERS[1:kk], nrow(myData), replace = T)