plant.metadata.k5: k5.structure

Description Usage Format Source

Description

A data.table with k = 5 membership by library

Usage

1

Format

A data.table with the following columns

bio.layers

RasterBrick with the 19 bioclim laaaters at a resolution of 2.5.

extent

The latitude / longitude extent of the dataset

l.states

SpatialPolygonsDataFrame with bounds of USA, MEX and CAN

o.states

SpatialPolygonsDataFrame with bounds of all non-USA admin

us.states

SpatialPolygonsDataFrame with bounds of USA states

rivers

SpatialLinesDataFrame with paths of rivers

countries

SpatialLinesDataFrame with boundaries of countries

coasts

SpatialLinesDataFrame with paths of coasts

great.lakes

SpatialPolygonsDataFrame with bounds of great lakes

lakes

SpatialPolygonsDataFrame with bounds of lakes

land

SpatialPolygonsDataFrame with bounds of land

Source

## Not run: field.metadata <- data.table(openxlsx::read.xlsx("~/Google Drive/Switchgrass-Genome/Switchgrass_V5_manuscript/raw_tables/GWAS_2019_Master Plant List.xlsx")) plant.metadata <- fread("~/Google Drive/Switchgrass-Genome/Switchgrass_V5_manuscript/raw_tables/PVDIV_Master Metadata File_9-3-2019.csv") plant.metadata <- plant.metadata[,c("PLANT_ID","ECOTYPE_SNP_CHLR","LATITUDE","LONGITUDE","COLLECTION_TYPE")] setnames(plant.metadata, c("id","cp.eco","lat","lon","ctype")) k5.assign.prob <- fread("~/Google Drive/Switchgrass-Genome/Switchgrass_V5_manuscript/raw_tables/Pvirgatum_4x_784g.5.meanQ", col.names = paste0("q",1:5)) tmp <- fread("~/Google Drive/Switchgrass-Genome/Switchgrass_V5_manuscript/raw_tables/Pvirgatum_4x_784g.5.meanQ.sample_order.txt", header = F, col.names = "id") coln <- paste0("q",1:5) setnames(k5.assign.prob, coln, c("TX","GC","MW","S.EC","N.EC")) coln <- c("TX","GC","MW","S.EC","N.EC") k5.assign.prob[,best := apply(.SD, 1, function(x) coln[which.max(x)]), .SDcols = coln] k5.assign.prob$qi.best <- sapply(1:nrow(k5.assign.prob), function(i){ x <- unlist(k5.assign.prob[i,coln,with = F]) y <- k5.assign.prob$best[i] return(x[y]) }) k5.assign.prob <- data.table(tmp, k5.assign.prob) plant.metadata.k5 <- merge(plant.metadata, k5.assign.prob, by = "id") d4 <- data.table(plant.metadata.k5) subpop.names <- c("TX", "GC", "S.EC","N.EC", "MW") d4[,subpop := factor(best, levels = subpop.names)] d4[,adm.rat := apply(.SD, 1, function(x) max(x[-which.max(x)]) / max(x)), .SDcols = subpop.names] d4[,is.adm := adm.rat > .01] d4[,qi2best := apply(.SD,1,function(x) subpop.names[order(-x)][2]), .SDcols = subpop.names] d4[,n3.admx := apply(.SD,1,function(x) sum(x > .2) > 2), .SDcols = subpop.names] plant.metadata.k5[,structure.order := as.numeric(factor(id, levels = d4$id))] d4[,subpop2best := factor(qi2best, levels = subpop.names)] setkey(d4, n3.admx, subpop, subpop2best, adm.rat) subpop.cols <- c("red2","salmon","cornflowerblue","blue2","orange") names(subpop.cols) <- subpop.names plant.metadata.k5[,best.col := subpop.cols[best]] save( plant.metadata.k5, file = "./data/plant.metadata.k5.rda") ## End(Not run)
LovellHAGSC/pvdiv.map documentation built on Nov. 5, 2019, 1:30 p.m.