Skip to content

Instantly share code, notes, and snippets.

View johnsonra's full-sized avatar

Randy Johnson johnsonra

View GitHub Profile
@johnsonra
johnsonra / airway_top_2000.R
Last active March 4, 2026 19:27
Top 2000 results from the Airway study
# Load necessary libraries
library(airway)
library(DESeq2)
library(org.Hs.eg.db)
library(dplyr)
# 1. Load the dataset
data("airway")
# 2. Build the DESeq2 object
@johnsonra
johnsonra / app.R
Last active February 26, 2026 22:40
# This is a version of the Shiny app found at https://github.com/BIFX547-26/ShinyHood for running with `shiny::runGist()`
library(shiny)
library(dplyr)
library(bslib)
library(DT)
# Load course data
courses <- read.csv("https://github.com/BIFX547-26/ShinyHood/raw/refs/heads/main/data/courses.csv", stringsAsFactors = FALSE)
@johnsonra
johnsonra / kappa.R
Last active March 2, 2022 13:56
Weighted Kappa
library(dplyr)
# example data
dat <- tibble(sid = c('SAC001', 'SAC002', 'SAC003', 'SAC004', 'SAC005',
'SAC006', 'SAC007', 'SAC008', 'SAC009', 'SAC010'),
theoretical_lab = c(1, 1, 1, 1, 2, 2, 2, 3, 3, 3),
lab1 = c(2, 1, 1, 3, 2, 1, 3, 3, 3, 3),
lab2 = c(1, 1, 2, 3, 2, 2, 1, 3, 2, 2),
lab3 = c(1, 1, 1, 2, 2, 2, 2, 3, 3, 2))
@johnsonra
johnsonra / colorblind_palettes.R
Last active April 14, 2020 15:01
Colorblind Palettes for R (see https://tinyurl.com/wjm6ryj)
############ nice colorblind pallete found at http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/ ###############
cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
############ another nice pallete from http://mkweb.bcgsc.ca/colorblind/img/colorblindness.palettes.simple.png #############
## ordering from dark to light
# indistinguishible pairs for tritanopia:
# *--------------------* *------------------------------------------------------* *---------------------*
@johnsonra
johnsonra / clean-up-boot-partition-ubuntu.md
Created October 26, 2018 20:40 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@johnsonra
johnsonra / stats4lunch_install.R
Last active May 4, 2018 18:56
Install R packages for the next Statistics for Lunch seminar
if(!require(tidyverse))
install.packages('tidyverse', dependencies = TRUE)
if(!require(seqplots))
{
source("https://bioconductor.org/biocLite.R")
biocLite("seqplots", suppressUpdates = TRUE)
}
if(!require(ggbio))
@johnsonra
johnsonra / transformations.R
Last active March 19, 2018 21:36
Transformation practice
# Practice Transformations
# after sourcing this gist, try to figure out what the best transformation is to make the association linear (without looking at the source code)
require(tidyverse)
N <- 500
# log normal association
set.seed(293847)
dat1 <- data_frame(x = rnorm(N),
@johnsonra
johnsonra / interactions.R
Last active February 8, 2018 13:25
Practice data for modeling interactions
# practice data for interactions
# this creates 3 data sets, dat1, dat2 and dat3
library(tidyverse)
set.seed(23478)
n <- 100
#################### interaction with a linear spline
@johnsonra
johnsonra / gfr.R
Created January 27, 2018 20:06
Simulated glomerular filtration rate as a function of age, gender and blood pressure
# simulated glomerular filtration rate as a function of age, gender and blood pressure
# linearity assumption may be violated, depending on the model
# multivariate normal assumption may be violated
# homoscedasticity assumption may be violated
require(tidyverse)
n <- 500
set.seed(239847)
@johnsonra
johnsonra / clt.R
Last active February 25, 2017 16:53
Central Limit Theorem Simulation
# clt.R
# function for exploring the Central Limit Theorem
# Randy Johnson
# distn = any function returning random numbers
# the first argument is assumed to be sample size!
# Sample size argument should be 'n'
# sample_size = number of random variables to draw for each mean
# ... = arguments to be passed to distn
clt.test <- function(distn, sample_size, seed=NULL, ...)