Skip to content

Instantly share code, notes, and snippets.

@robiwangriff
robiwangriff / ngs2gel_basic.r
Last active June 5, 2024 15:08
ngs2gel_basic
ngs2gel.b<-function(spc,tax,subs=0.005,band_multiplier=5,label_tax_1="Phylum",
label_tax_2="Order", band_col="grey",y_labs_remover=2,y_labs_size=1){
#libs used
require(reshape2)
require(vegan)
require(ggh4x)
require(cowplot)
require(ggrepel)
@robiwangriff
robiwangriff / amplicon_help.r
Last active October 19, 2023 10:41
amplicon_helpers
##source_gist("https://gist.github.com/robiwangriff/79633a738b128e64226bf58381232da7")
#' # 1. Merge and filter
#'A small function to merge and align, and output a list containing the aligned $spc, $env, and $tax
#' files. The main part of this is merge() and requires specifying two "common reference" vectors in both datasets.
aligner<-function(spc,env,tax=NULL, spc_id="row.names",env_id="row.names",tax_id="row.names",transpose_spc=FALSE){
#transpose the spc file so sample IDs are rows (and row names)
spc.t<-spc
@robiwangriff
robiwangriff / ngs2gel.r
Last active September 22, 2023 10:38
do you remember Spangles? have you visualized microbes on acrylamide gels? do you want to view amplicon data as a gel image?
#################################################################################################################
#install
#library(devtools)
#source_gist("https://gist.github.com/robiwangriff/62ee1fd1adfcb50cfd5520075ce9da86")
#spc= a species(cols) by samples (rows) data frame
#env= an environmental metadata data frame, aligned with spc. Used to order and label samples on x axis (#the order loaded on gel)
#tax= a taxonomy file with sequences/OTU ids as row names - normally would match colnames of spc df. Though shouldnt matter.
#subs= Unlike real gels, we cant plot the abundance of every species. This sets a relative abundance threshold for taxa to plot.