Skip to content

Instantly share code, notes, and snippets.

@padpadpadpad
Last active December 11, 2017 10:27
Show Gist options
  • Save padpadpadpad/456429fb42a5473afdccd4d203aa886e to your computer and use it in GitHub Desktop.
Save padpadpadpad/456429fb42a5473afdccd4d203aa886e to your computer and use it in GitHub Desktop.
# phylogenetic tree options
# using fasttree
# load packages
library(phyloseq)
library(tidyr)
library(dplyr)
library(dada2)
# NEED TO INSTALL FASTTREE
# load in alignment file ####
myalignment <- read.dna("where/alignment/file/is.fasta",format="fasta",as.matrix=TRUE)
# run using FastTree
system('~/where/FastTree/is/FastTree -nt where/alignment/file/is.fasta > where/to/save/alignment/tree')
# this took 14 minutes
# load in data needed for the phyloseq objects
seqtab <- readRDS('where/seqtab/is/seqtab.rds')
meta <- read.csv('where/metadata/is/metadata.csv')
taxtab <- readRDS('where/taxtab/is/taxtab.rds')
tree <- read_tree('where/tree/is/tree')
# change row names
rownames(meta) <- meta$SampleID
# make phyloseq object
ps <-phyloseq(tax_table(taxtab),
sample_data(meta),
otu_table(seqtab, taxa_are_rows = FALSE),
phy_tree(tree))
# overwrite previous phyloseq object
saveRDS(ps, 'where/to/save/phyloseq/object/ps.rds')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment