We have methylation data at 480K sites from the illumina 450 methylation chip for 96 controls and 97 asthmatics from the ICAC project.
NOTE
see this site: http://www.ats.ucla.edu/stat/r/dae/t_test_power2.htm
We have methylation data at 480K sites from the illumina 450 methylation chip for 96 controls and 97 asthmatics from the ICAC project.
NOTE
see this site: http://www.ats.ucla.edu/stat/r/dae/t_test_power2.htm
Notes:
I've tried to break up in to separate pieces, but it's not always possible: e.g. knowledge of data structures and subsetting are tidy intertwined.
Level of Bloom's taxonomy listed in square brackets, e.g. http://bit.ly/15gqPEx. Few categories currently assess components higher in the taxonomy.
COUNTYFIPS | NAME | STATEPLANEFIPS | EPSG | |
---|---|---|---|---|
16079 | Shoshone County | 1103 | 26970 | |
16073 | Owyhee County | 1103 | 26970 | |
16071 | Oneida County | 1101 | 26968 | |
16077 | Power County | 1101 | 26968 | |
16075 | Payette County | 1103 | 26970 | |
06115 | Yuba County | 0402 | 26942 | |
06111 | Ventura County | 0405 | 26945 | |
06113 | Yolo County | 0402 | 26942 | |
31177 | Washington County | 2600 | 32104 |
This gist shows in two steps how to tilt and stack maps using ggplot2 in order to create an image like this one: [![enter image description here][1]][1]
Let's load the necessary libraries and data to use a reproducible example:
# load libraries
library(rgeos)
library(UScensus2000tract)
library(ggplot2)
library(tweenr) # Available on CRAN | |
library(ggforce) # Install from thomasp85/ggforce | |
library(gganimate) # Install from dgrtwo/gganimate | |
set.seed(2) | |
x <- sample(9,20, prob=c(1,2,3,4,5,4,3,2,1), replace=T) | |
df <- data.frame(x = x, y = 15) | |
dfs <- list(df) | |
for(i in seq_len(nrow(df))) { | |
dftemp <- tail(dfs, 1) | |
dftemp[[1]]$y[i] <- sum(dftemp[[1]]$x[seq_len(i)] == dftemp[[1]]$x[i]) |
# Download elevation tif from eg http://www.eea.europa.eu/data-and-maps/data/digital-elevation-model-of-europe | |
# First, convert elevation tif to a space delimited xyz (lng lat elevation) file | |
# $ gdal_translate -of XYZ elevation3x3.tif /tmp/file.xyz | |
df <- read_delim('/tmp/file.xyz', delim=' ', col_names=FALSE) | |
df %>% | |
mutate(X3 = na_if(X3, 0)) %>% | |
ggplot(aes(X1, -X2 + 20 * X3/max(X3, na.rm=TRUE), group=X2)) + | |
geom_line(size=0.05) + |
library(ggplot2) | |
library(gganimate) | |
library(sf) | |
earth <- sf::st_as_sf(rnaturalearth::countries110) | |
views <- data.frame(rbind( | |
st_bbox(earth[earth$name == 'Denmark',]), | |
st_bbox(earth[earth$name == 'Australia',]) | |
)) | |
p <- ggplot() + | |
geom_sf(data = earth, fill = 'white') + |
#!/bin/sh | |
# Simplified template based on a script from Jonathan Heiss | |
# create batchtools.lsf.tmpl in the working directory - this template used for child jobs | |
cat <<'TEMPLATE' > batchtools.lsf.tmpl | |
## Default resources can be set in your .batchtools.conf.R by defining the variable | |
## 'default.resources' as a named list. | |
#BSUB-J <%= job.name %> # Name of the job | |
#BSUB-o <%= log.file %> # Output is sent to logfile, stdout + stderr by default |
library(gganimate) # thomasp85/gganimate | |
library(cartogram) | |
library(geogrid) # Need github version jbaileyh/geogrid | |
library(rnaturalearth) | |
library(sf) | |
library(scico) | |
us <- ne_states('united states of america', returnclass = 'sf') | |
us <- us[!us$woe_name %in% c('Alaska', 'Hawaii'), ] | |
us <- st_transform(us, '+proj=eqdc +lat_0=39 +lon_0=-96 +lat_1=33 +lat_2=45 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs') |
library(tidyverse) | |
library(gganimate) | |
library(mgcv) | |
library(mvtnorm) | |
# Fit a GAM to the data | |
mod <- gam(hp ~ s(mpg), data=mtcars, method="REML") | |
# Get the linear prediction matrix | |
newdat = data.frame( |