Skip to content

Instantly share code, notes, and snippets.

@jnpaulson
jnpaulson / server.R
Created May 12, 2016 14:03 — forked from xiaodaigh/server.R
A gist of programatically changing panel tabs in Shiny
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution. This is
# called whenever the inputs change. The renderers defined
# below then all use the value computed from this expression
data <- reactive({
dist <- switch(input$dist,
@jnpaulson
jnpaulson / continentInfo.tsv
Created February 3, 2016 21:46
Country and continent information
Algeria Africa
Angola Africa
Benin Africa
Botswana Africa
Burkina Faso Africa
Burundi Africa
Cameroon Africa
Cape Verde Africa
Central African Republic Africa
Chad Africa
@jnpaulson
jnpaulson / springer-free-maths-books.md
Created December 29, 2015 15:14 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links
@jnpaulson
jnpaulson / merge_hmp_msd16s
Created May 8, 2015 21:39
merge hmp and msd16s
load("HMPv35_100nt.biom_MRexperiment.rdata")
library(msd16s)
k = which(pData(obj)$bodysite == "UBERON_stool")
obj = obj[,k]
mergeData = function(o1,o2,norm=FALSE){
o1names = rownames(o1)
o2names = rownames(o2)
@jnpaulson
jnpaulson / import_biom2.R
Last active February 22, 2018 01:47
This will convert a biom class object into a phyloseq object.
import_biom2 <- function(x,
treefilename=NULL, refseqfilename=NULL, refseqFunction=readDNAStringSet, refseqArgs=NULL,
parseFunction=parse_taxonomy_default, parallel=FALSE, version=1.0, ...){
# initialize the argument-list for phyloseq. Start empty.
argumentlist <- list()
x = biom(x)
b_data = biom_data(x)
b_data_mat = as(b_data, "matrix")
setMethod("normFactors", signature(object="MRexperiment"),
function(object) {
nf <- pData(obj@expSummary$expSummary)[["normFactors"]]
nf <- unlist(nf)
names( nf ) <- sampleNames(object)
nf
})
setReplaceMethod("normFactors", signature(object="MRexperiment", value="numeric"),
function( object, value ) {
@jnpaulson
jnpaulson / predictPatient.R
Created November 23, 2014 22:20
predict patient from k mds coordinates and accuracy
j = unlist(locals[2:3])
obj2 = obj[,j]
sampleID2 = sampleID[j]
mat = MRcounts(obj2,norm=TRUE,log=TRUE)
otusToKeep <- which(rowSums(mat)>0)
otuVars<-rowSds(mat[otusToKeep,])
otuIndices<-otusToKeep[order(otuVars,decreasing=TRUE)[1:1000]]
mat <- mat[otuIndices,]
mat = t(mat)
@jnpaulson
jnpaulson / plotAG.R
Last active August 29, 2015 14:09
pca/pcoa plots of the american gut consortium data
require(vegan)
require(biom)
require(metagenomeSeq)
files = grep(".biom$",list.files(),value=TRUE)
files2= grep(".txt",list.files(),value=TRUE)
files3 = sprintf("%s_MRexperiment.rdata",files)
# This generates the data - only run once.
for(i in 1:length(files)){
@jnpaulson
jnpaulson / grabAG.sh
Created November 15, 2014 23:49
grab data from the american gut consortium
#!/bin/bash
# grab the biom data
wget https://github.com/biocore/American-Gut/raw/master/data/PGP/PGP_100nt.biom.gz
wget https://github.com/biocore/American-Gut/raw/master/data/HMP/HMPv35_100nt.biom.gz
wget https://github.com/biocore/American-Gut/raw/master/data/GG/GG_100nt.biom.gz
wget https://github.com/biocore/American-Gut/raw/master/data/AG/AG_100nt.biom.gz
gunzip *
# grab the phenodata
@jnpaulson
jnpaulson / dcbusmap.geojson
Last active August 29, 2015 14:08
DC bus station geojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.