bamdat2mat: Write BAM dat file values to a set of matrices and data...

View source: R/bamdat2mat.r

bamdat2matR Documentation

Write BAM dat file values to a set of matrices and data frames

Description

The script converts objects defined in the DATA SECTION of BAM into a set of data objects that are more easily read by humans.

Usage

bamdat2mat(
  CommonName = NULL,
  bam = NULL,
  writeFiles = "csv",
  writeFiles_dir = paste("bamdat2mat", writeFiles, sep = "_"),
  prompt_me = TRUE
)

Arguments

CommonName

Common name of species modeled in BAM files. Only used when accessing dat, tpl, and cxx character vectors named as e.g. dat_CommonName

bam

Object returned from bam2r.

writeFiles

File extension of files to write output data to. Current options include "csv". Set to any other value to run the function without writing output.

writeFiles_dir

Name of directory to write files to.

Value

Silently returns a list of all data objects,

Examples

## Not run: 
# Read in any of the current BAM models
dm_AtMe <- bamdat2mat("AtlanticMenhaden")
dm_BlSB <- bamdat2mat("BlackSeaBass")
dm_BlTi <- bamdat2mat("BluelineTilefish")
dm_Cobi <- bamdat2mat("Cobia")
dm_GagG <- bamdat2mat("GagGrouper")
dm_GrTr <- bamdat2mat("GrayTriggerfish")
dm_GrAm <- bamdat2mat("GreaterAmberjack")
dm_ReGr <- bamdat2mat("RedGrouper")
dm_RePo <- bamdat2mat("RedPorgy")
dm_ReSn <- bamdat2mat("RedSnapper")
dm_SnGr <- bamdat2mat("SnowyGrouper")
dm_Tile <- bamdat2mat("Tilefish")
dm_VeSn <- bamdat2mat("VermilionSnapper")

# Write data objects to csv
dm_AtMe <- bamdat2mat("AtlanticMenhaden",writeFiles="csv")

# Or don't write them and just do stuff with the data objects
dm_BlSB <- bamdat2mat("BlackSeaBass",writeFiles = "")
matplot(rownames(dm_BlSB$obs_L),dm_BlSB$obs_L,type="l")

agec <- dm_BlSB$obs_agec
par(mfrow=c(length(agec),1),mar=c(2,2,1,1),mgp=c(.8,.1,0),tck=-0.01)
lapply(seq_along(agec),function(i){
nmi <- names(agec)[i]
x <- agec[[i]]
image(as.numeric(rownames(x)),as.numeric(colnames(x)),x,xlab="year",ylab="age",main=nmi)
})

## End(Not run)

nikolaifish/bamExtras documentation built on July 21, 2023, 8:26 a.m.