Title: | Collection and Analysis of Otolith Shape Data |
---|---|
Description: | Studies otolith shape variation among fish populations. Otoliths are calcified structures found in the inner ear of teleost fish and their shape has been known to vary among several fish populations and stocks, making them very useful in taxonomy, species identification and to study geographic variations. The package extends previously described software used for otolith shape analysis by allowing the user to automatically extract closed contour outlines from a large number of images, perform smoothing to eliminate pixel noise, choose from conducting either a Fourier or wavelet transform to the outlines and visualize the mean shape. The output of the package are independent Fourier or wavelet coefficients which can be directly imported into a wide range of statistical packages in R. The package might prove useful in studies of any two dimensional objects. |
Authors: | Lisa Anne Libungan [aut, cre], Snaebjorn Palsson [aut, ths] |
Maintainer: | Lisa Anne Libungan <[email protected]> |
License: | GPL(>=2) |
Version: | 0.1-5 |
Built: | 2024-10-12 03:54:44 UTC |
Source: | https://github.com/lisalibungan/shaper |
Plots data clusters
cluster.plot( ddata, classes, main="", col.stock=NULL, plotCI = FALSE, conf.level = 0.68, ...)
cluster.plot( ddata, classes, main="", col.stock=NULL, plotCI = FALSE, conf.level = 0.68, ...)
ddata |
Matrix of points |
classes |
A factor including the cluster values |
main |
Title for the plot |
col.stock |
Colors for the plotted classes |
plotCI |
Plot means with confidence intervals |
conf.level |
The confidence interval for the standard error of the mean |
... |
Additional parameters to be passed to 'plot' or 'ldahist' if one dimension |
Lisa Anne Libungan
Oksanen, J., Blanchet, F.G., Kindt, R., Legendre, P., Minchin, P.R., O'Hara, R.B., Simpson, G.L., Solymos, P., Stevens, M.H.H. and Wagner, H. (2013). vegan
: Community Ecology Package. R package version 2.0-10.
data(shape) library(vegan) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) eig=eigenvals(cap.res,constrained=TRUE) eig.ratio = eig/sum(eig) cluster.plot(scores(cap.res)$sites[,1:2],getMasterlist(shape)$pop ,plotCI=TRUE ,xlab=paste("CAP1 (",round(eig.ratio[1]*100,1),"%)",sep="") ,ylab=paste("CAP2 (",round(eig.ratio[2]*100,1),"%)",sep="") ,main="Canonical clustering" )
data(shape) library(vegan) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) eig=eigenvals(cap.res,constrained=TRUE) eig.ratio = eig/sum(eig) cluster.plot(scores(cap.res)$sites[,1:2],getMasterlist(shape)$pop ,plotCI=TRUE ,xlab=paste("CAP1 (",round(eig.ratio[1]*100,1),"%)",sep="") ,ylab=paste("CAP2 (",round(eig.ratio[2]*100,1),"%)",sep="") ,main="Canonical clustering" )
Determine the outline of otolith images in jpeg format which have been stored in the Fixed
folder.
detect.outline(object, threshold=0.2, mouse.click=FALSE, display.images=FALSE, write.outline.w.org=FALSE)
detect.outline(object, threshold=0.2, mouse.click=FALSE, display.images=FALSE, write.outline.w.org=FALSE)
object |
|
threshold |
Grayscale threshold. Value between 0 and 1. |
mouse.click |
If TRUE, the user clicks where the starting point for the otolith contour extraction algorithm should start. Default is the center of the image. Could be good to set as TRUE if the otolith detection produces an error. |
display.images |
If TRUE, each image is displayed and the user can visualize how the outline is captured |
write.outline.w.org |
If TRUE, the outline is written on top of the original image using the function |
Based on the Conte function (Claude 2008)
A shapeR
object with otolith outlines in the slot outline.list
Lisa Anne Libungan & Snaebjorn Palsson
Claude, J. (2008). Morphometrics with R. Springer. 316 p.
Urbanek, S. (2014). jpeg
: Read and write JPEG images. R package version 0.1-8.
Bivand, R., Leisch, F. & Maechler, M. (2011) pixmap
: Bitmap Images (”Pixel Maps”). R package version 0.4-11.
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
## Not run: #Use test data from Libungan and Palsson (2015): shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape, threshold=0.2,write.outline.w.org = TRUE) ## End(Not run)
## Not run: #Use test data from Libungan and Palsson (2015): shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape, threshold=0.2,write.outline.w.org = TRUE) ## End(Not run)
Link the original info file to the otolith coefficients
enrich.master.list(object, folder_name = "folder", pic_name = "picname", calibration = "cal", include.wavelet = TRUE, include.fourier = TRUE, n.wavelet.levels = 5, n.fourier.freq = 12,...)
enrich.master.list(object, folder_name = "folder", pic_name = "picname", calibration = "cal", include.wavelet = TRUE, include.fourier = TRUE, n.wavelet.levels = 5, n.fourier.freq = 12,...)
object |
A |
folder_name |
Should contain the first letters of the area and the serie or station number of the sample, for example: "IC" |
pic_name |
Should contain the serie number of a given sample and fish number, for example "403_2" (not including the .jpg extension) |
calibration |
The name of the column where the pixels to measurement calibration is located |
include.wavelet |
If TRUE, the wavelet coefficient are included in the master.list |
include.fourier |
If TRUE then the Normalized Elliptic Fourier coefficients are included in the master.list |
n.wavelet.levels |
Integer saying how many levels of wavelet levels should be included |
n.fourier.freq |
Integer saying how many Fourier frequency levels should be included |
... |
Additional parameter for |
A shapeR
object with values in slots:
wavelet.coef
fourier.coef
shape
filter
master.list
Lisa Anne Libungan
## Not run: data(shape) shape = generateShapeCoefficients(shape) shape = enrich.master.list(shape) ## End(Not run)
## Not run: data(shape) shape = generateShapeCoefficients(shape) shape = enrich.master.list(shape) ## End(Not run)
Estimate outline reconstruction using a different number of coefficients of wavelet and Fourier compared to the original otolith
estimate.outline.reconstruction(object, ...)
estimate.outline.reconstruction(object, ...)
object |
|
... |
Additional parameters to be passed to 'plot' and 'points' |
A list containing values
w.dev.m a list for number of coefficients for mean error of wavelet reconstruction
w.dev.sd a list for number of coefficients for standard deviation of wavelet reconstruction
f.power.total Fourier power for number of Fourier harmonics
Lisa Anne Libungan
Claude, J. (2008) Morphometrics with R. Springer. 316 p.
## Not run: data(shape) estimate.outline.reconstruction(shape) ## End(Not run)
## Not run: data(shape) estimate.outline.reconstruction(shape) ## End(Not run)
The file's columns are:
country
station
pop
stockID
day
month
year
lat
lon
fishno
length_cm
weight_g
age
sex
maturity
folder
picname
cal
data(FISH)
data(FISH)
An example data file
https://github.com/lisalibungan/shapeR
Generates shape variables based on Fourier/wavelet reconstruction. Wavelet coefficients for wavelet. Basic shape parameters are also collected (area, length, width, perimeter).
generateShapeCoefficients(object,...)
generateShapeCoefficients(object,...)
object |
|
... |
Additional parameters to be passed to the |
A shapeR
object with values in slots:
wavelet.coef.raw
fourier.coef.raw
shape.coef.raw
Lisa Anne Libungan & Snaebjorn Palsson
Nason, G. (2012). wavethresh
: Wavelets statistics and transforms. R package, version 4.5.
Claude, J. (2008). Morphometrics with R. Springer. 316 p.
## Not run: data(shape) shape = generateShapeCoefficients(shape) ## End(Not run)
## Not run: data(shape) shape = generateShapeCoefficients(shape) ## End(Not run)
Returns the Fourier coefficients determined in stdCoefs
.
Returns only values as set in setFilter
getFourier(object)
getFourier(object)
object |
|
The Fourier coefficients for all fish as determined by setFilter
Lisa Anne Libungan
Returns selected values from master.list
getMasterlist(object, useFilter = TRUE)
getMasterlist(object, useFilter = TRUE)
object |
|
useFilter |
If TRUE, the master.list values are filtered by the slot |
The master.list
is filtered by the slot filter
if the useFilter
is TRUE, else no filtering is done.
Lisa Anne Libungan
Returns shape variables length, width, perimeter and area determined in generateShapeCoefficients
.
Returns only values as set in the slot filter
.
These variables can only be obtained if the calibration measurements in pixels have been registered in the csv data file in a column labelled 'cal' (see example data file). To get the calibration measurements, use a image manipulation program and measure 1mm on the calibration measurement stick (that was taken for that particular dataset) and register how many pixels 1mm is into the column 'cal'.
getMeasurements(object)
getMeasurements(object)
object |
|
A data frame with all valid fish as determined by the slot filter
and with columns:
otolith.area
otolith.length
otolith.width
otolith.perimeter
Lisa Anne Libungan
data(shape) # Calculate the mean otolith area for each fish population # The results are in square mm since the calibration ('cal') column # in the data file is in pixels (1 mm/pixel). tapply(getMeasurements(shape)$otolith.area, getMasterlist(shape)$pop,mean)
data(shape) # Calculate the mean otolith area for each fish population # The results are in square mm since the calibration ('cal') column # in the data file is in pixels (1 mm/pixel). tapply(getMeasurements(shape)$otolith.area, getMasterlist(shape)$pop,mean)
Returns the standardized Fourier coefficients determined in stdCoefs
.
Returns only values as set in the slot filter
getStdFourier(object)
getStdFourier(object)
object |
|
The standardized Fourier coefficients for all valid fish as determined by the slot filter
Lisa Anne Libungan
Returns the simple shape variables determined in stdCoefs
.
Returns only values as set in the slot filter
getStdMeasurements(object)
getStdMeasurements(object)
object |
|
A data frame with all valid fish as determined by the slot filter
. Returns only variables that have not been removed after standardization.
Lisa Anne Libungan
data(shape) #Calculate the mean standardized otolith length for each fish population tapply(getStdMeasurements(shape)$otolith.length, getMasterlist(shape)$pop,mean)
data(shape) #Calculate the mean standardized otolith length for each fish population tapply(getStdMeasurements(shape)$otolith.length, getMasterlist(shape)$pop,mean)
Returns the standardized wavelet coefficients determined in stdCoefs
.
Returns only values as set in the slot filter
getStdWavelet(object)
getStdWavelet(object)
object |
|
The standardized wavelet coefficients for all valid fish as determined by the slot filter
Lisa Anne Libungan
Returns the wavelet coefficients determined in generateShapeCoefficients
.
Returns only values as set in the slot filter
getWavelet(object)
getWavelet(object)
object |
|
The wavelet coefficients for all valid fish as determined by the slot filter
Lisa Anne Libungan
Show graphs of the reconstruction using different number of levels of wavelet reconstruction and Fourier power using different number of Fourier harmonics. Uses the output from estimate.outline.reconstruction
outline.reconstruction.plot(outline.rec.list,ref.w.level=5, ref.f.harmonics=12,max.num.harmonics=32,...)
outline.reconstruction.plot(outline.rec.list,ref.w.level=5, ref.f.harmonics=12,max.num.harmonics=32,...)
outline.rec.list |
The output from estimate.outline.reconstruction |
ref.w.level |
Reference level for graphical purposes. The default is 5 as is the default of shapeR. |
ref.f.harmonics |
Reference Fourier harmonize. The default is 12 as is the default in shapeR. |
max.num.harmonics |
Maxinum number of Fourier harmonics to be shown |
... |
Additional parameters to be passed to 'plot' |
Lisa Anne Libungan
## Not run: data(shape) est.list = estimate.outline.reconstruction(shape) outline.reconstruction.plot(est.list,panel.first = grid()) ## End(Not run)
## Not run: data(shape) est.list = estimate.outline.reconstruction(shape) outline.reconstruction.plot(est.list,panel.first = grid()) ## End(Not run)
The mean and standard deviation of the Fourier coefficients
plotFourier(object, coef.index=NULL,class.name=NULL,useStdcoef=FALSE, ...)
plotFourier(object, coef.index=NULL,class.name=NULL,useStdcoef=FALSE, ...)
object |
|
coef.index |
An index vector for which fourier coefficents to be shown. Default is |
class.name |
Column name in master list for partitioning the data into groups and showing the ratio of variance among to the sum of variance among and variance within. |
useStdcoef |
Boolean saying if to use the standardized coefficients or not |
... |
Additional parameters to be passed to 'plot' |
Lisa Anne Libungan
data(shape) shape = stdCoefs(shape,classes="pop","length_cm") plotFourier(shape,class.name= "pop",useStdcoef=TRUE)
data(shape) shape = stdCoefs(shape,classes="pop","length_cm") plotFourier(shape,class.name= "pop",useStdcoef=TRUE)
A function for showing the mean otolith shape based on Fourier reconstruction
plotFourierShape(object, class.name, show.angle = FALSE,lty=1:5,col=1:6, ...)
plotFourierShape(object, class.name, show.angle = FALSE,lty=1:5,col=1:6, ...)
object |
A |
class.name |
A string as the column name in the master list |
show.angle |
If TRUE angles are shown on the plot |
lty , col
|
Vector of line types and colors. Values are used cyclically. |
... |
Additional parameters to be passed to 'plot' |
Lisa Anne Libungan
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
data(shape) plotFourierShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1)
data(shape) plotFourierShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1)
The mean and standard deviation of the wavelet coefficients
plotWavelet(object, level, start.angle = 0, class.name=NULL,useStdcoef=FALSE,...)
plotWavelet(object, level, start.angle = 0, class.name=NULL,useStdcoef=FALSE,...)
object |
A |
level |
The wavelet level to be shown |
start.angle |
The angle in degrees, the x-axis should start on |
class.name |
Column name in master list for partitioning the data into groups and showing the ratio of variation among groups. |
useStdcoef |
Choose "TRUE" or "FALSE" if coefficients should be standardized or not |
... |
Additional parameters to be passed to 'plot' |
Lisa Anne Libungan
data(shape) shape = stdCoefs(shape,classes="pop","length_cm") plotWavelet(shape,level=5,class.name= "pop",useStdcoef=TRUE)
data(shape) shape = stdCoefs(shape,classes="pop","length_cm") plotWavelet(shape,level=5,class.name= "pop",useStdcoef=TRUE)
A function for showing the mean otolith shape based on wavelet reconstruction
plotWaveletShape(object, class.name,show.angle=FALSE,lty=1:5,col=1:6,...)
plotWaveletShape(object, class.name,show.angle=FALSE,lty=1:5,col=1:6,...)
object |
A |
class.name |
A string as the column name in the master list |
show.angle |
If TRUE angles are shown on the plot |
lty , col
|
Vector of line types and colors. Values are used cyclically. |
... |
Additional parameters to be passed to 'plot' |
Lisa Anne Libungan
Nason, G. (2012) wavethresh
: Wavelets statistics and transforms, version 4.5. R package.
data(shape) plotWaveletShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1)
data(shape) plotWaveletShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1)
Reads an updated master list. This is important to run if you want to ensure that a updated master list is used in the analysis.
read.master.list(object, ...)
read.master.list(object, ...)
object |
A |
... |
Additional parameter for |
shapeR
object with values in slots:
master.list.org
Lisa Anne Libungan
A function for removing an otolith outline from the file 'outline.list'. Typically done if the image is of bad quality and needs to be enhanced in a image processing software
remove.outline(object, folder = "", fname = "")
remove.outline(object, folder = "", fname = "")
object |
A |
folder |
The folder name where the outline that needs to be removed is stored |
fname |
The file name of the outline to be removed |
shapeR
object
Lisa Anne Libungan
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
## Not run: #Use test data from example in Libungan and Palsson (2015): shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape) #If otolith outline in folder IC named 403_1 needs to be removed shape = remove.outline(shape, "IC", "403_1") ## End(Not run)
## Not run: #Use test data from example in Libungan and Palsson (2015): shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape) #If otolith outline in folder IC named 403_1 needs to be removed shape = remove.outline(shape, "IC", "403_1") ## End(Not run)
Sets a filter on master.list
. Here it is possible to filter the master.list
by specific ages, maturity stages, areas, etc.
If no value is set, all data with shape parameters are used
setFilter(object, filter)
setFilter(object, filter)
object |
A |
filter |
A vector restricting the new filter value. Only otoliths having shape parameters are selected. |
A shapeR
object with the slot filter
set.
Lisa Anne Libungan
data(shape) #Filter only Icelandic and Norwegian samples shape = setFilter(shape, getMasterlist(shape, useFilter = FALSE)$pop %in% c("NO","IC")) table(getMasterlist(shape)$pop) #Reset filter shape = setFilter(shape) table(getMasterlist(shape)$pop)
data(shape) #Filter only Icelandic and Norwegian samples shape = setFilter(shape, getMasterlist(shape, useFilter = FALSE)$pop %in% c("NO","IC")) table(getMasterlist(shape)$pop) #Reset filter shape = setFilter(shape) table(getMasterlist(shape)$pop)
The shape coefficients have been generated. The wavelet coefficients have been standardized using pop and length_cm.
data(shape)
data(shape)
A shapeR class including 160 images
The class slot's are as follows:
project.path. A path as "ShapeAnalysis/"
info.file. A file as FISH.csv. The information is stored in the data frame master.list
outline.list. A list with three elements (IC, NO, SC) which give a list of the otolith outlines
filter. A logical vector showing which elements of the master list have valid otoliths
fourier.coef. A matrix of the Normalized Elliptic Fourier coefficients
wavelet.coef. A matrix of the wavelet coefficients
shape. A matrix of shape variables after scaling according to calibration otolith.area, otolith.length, otolith.width, otolith.perimeter.
fourier.coef.std. A matrix which will contain standardized Fourier coefficients
wavelet.coef.std. A matrix which will contain standardized wavelet coefficients
shape.coef.raw. A matrix of shape variables before scaling according to calibration otolith.area, otolith.length, otolith.width, otolith.perimeter.
master.list. The contents of the info.file
https://github.com/lisalibungan/shapeR
Collection and analysis of otolith shape data
a shapeR class
shapeR(project.path, info.file, ...)
shapeR(project.path, info.file, ...)
project.path |
The base project path where the images are stored |
info.file |
The information file which store the information on the fish and otoliths. This is the base for the master.list |
... |
Additional parameters to be passed to 'read.csv' for reading the info.file |
a shapeR
object
project.path
Path to the project where the images are stored
info.file
Info file containing fish and otolith information
master.list.org
The contents of the info.file
master.list
The contents of the info.file
with added shape parameters and descriptors
outline.list.org
A list of all the original otolith outlines
outline.list
A list of all the otolith outlines. It returns a list of smoothed if contour smoothing (usingsmoothout
) has been conducted.
filter
A logical vector selecting the otoliths used for analysis
wavelet.coef.raw
The wavelet coefficients for all the otolith outlines
wavelet.coef
The wavelet coefficients after aligning with the info.file
. The data is generated when enrich.master.list is run
wavelet.coef.std
The standardized wavelet coefficients. The data is generated when stdCoefs is run
wavelet.coef.std.removed
The index of the removed wavelet coefficients after standardization. The data is generated when stdCoefs is run
fourier.coef.raw
The Fourier coefficients for all the otolith outlines
fourier.coef
The Fourier coefficients for after aligning with the info file. The data is generated when enrich.master.list is run
fourier.coef.std
The standardized Fourier coefficients. The data is generated when stdCoefs is run
fourier.coef.std.removed
The index of the removed Fourier coefficents after standardization. The data is generated when stdCoefs is run
shape.coef.raw
The uncalibrated shape measurements for all the otoliths. The shape parameters are: otolith.area, otolith.length, otolith.width, otolith.perimeter
shape.coef
The shape measurements for after aligning with the info file. The shape parameters have been calibrated using the calibration parameter as registered in the datafile as the column 'cal'.
shape.std
The standardized shape measurements. The data is generated when stdCoefs is run
shape.std.removed
The index of the removed shape measurements after standardization. The data is generated when stdCoefs is run
Lisa Anne Libungan & Snaebjorn Palsson
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
https://github.com/lisalibungan/shapeR
## Not run: # This example has two sections: (1) Demonstration of how a shapeR object # is analyzed and (2) How to create a shapeR object from an archive of # image files. #----------------------------------------- # Section 1: Analyzing a shapeR object data(shape) #Standardize coefficients shape = stdCoefs(shape,"pop","length_cm") #Visualize Wavelet and Fourier coefficients plotWavelet(shape,level=5,class.name= "pop",useStdcoef=TRUE) plotFourier(shape,class.name= "pop",useStdcoef=TRUE) #Examine the mean shapes plotWaveletShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1) plotFourierShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1) #Canonical analysis library(vegan) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) anova(cap.res) #Visualize the canonical scores eig=eigenvals(cap.res,constrained=TRUE) eig.ratio = eig/sum(eig) cluster.plot(scores(cap.res)$sites[,1:2],getMasterlist(shape)$pop ,plotCI=TRUE ,xlab=paste("CAP1 (",round(eig.ratio[1]*100,1),"%)",sep="") ,ylab=paste("CAP2 (",round(eig.ratio[2]*100,1),"%)",sep="") ,main="Canonical clustering" ) #Only analyze Icelandic and Norwegian samples shape = setFilter(shape, getMasterlist(shape, useFilter = FALSE)$pop %in% c("NO","IC")) #Classifier on standardized wavelet lda.res.w = lda(getStdWavelet(shape),getMasterlist(shape)$pop,CV=TRUE) ct.w = table(getMasterlist(shape)$pop,lda.res.w$class) diag(prop.table(ct.w, 1)) # Total percent correct sum(diag(prop.table(ct.w))) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) anova(cap.res) #Classifier on canoncial values lda.res.w = lda(scores(cap.res)$sites,getMasterlist(shape)$pop,CV=TRUE) ct.w = table(getMasterlist(shape)$pop,lda.res.w$class) diag(prop.table(ct.w, 1)) # Total percent correct sum(diag(prop.table(ct.w))) #----------------------------------------- # Section 2: Creating a shapeR object from image files # The following example requires the user to download an archive of JPEG # files from https://github.com/lisalibungan/shapeR/ # place the ShapeAnalysis directory inside the working directory. shape = shapeR("~/ShapeAnalysis/","FISH.csv") shape = detect.outline(shape,write.outline.w.org = TRUE) shape = generateShapeCoefficients(shape) shape = enrich.master.list(shape) ## End(Not run)
## Not run: # This example has two sections: (1) Demonstration of how a shapeR object # is analyzed and (2) How to create a shapeR object from an archive of # image files. #----------------------------------------- # Section 1: Analyzing a shapeR object data(shape) #Standardize coefficients shape = stdCoefs(shape,"pop","length_cm") #Visualize Wavelet and Fourier coefficients plotWavelet(shape,level=5,class.name= "pop",useStdcoef=TRUE) plotFourier(shape,class.name= "pop",useStdcoef=TRUE) #Examine the mean shapes plotWaveletShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1) plotFourierShape(shape, "pop",show.angle = TRUE,lwd=2,lty=1) #Canonical analysis library(vegan) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) anova(cap.res) #Visualize the canonical scores eig=eigenvals(cap.res,constrained=TRUE) eig.ratio = eig/sum(eig) cluster.plot(scores(cap.res)$sites[,1:2],getMasterlist(shape)$pop ,plotCI=TRUE ,xlab=paste("CAP1 (",round(eig.ratio[1]*100,1),"%)",sep="") ,ylab=paste("CAP2 (",round(eig.ratio[2]*100,1),"%)",sep="") ,main="Canonical clustering" ) #Only analyze Icelandic and Norwegian samples shape = setFilter(shape, getMasterlist(shape, useFilter = FALSE)$pop %in% c("NO","IC")) #Classifier on standardized wavelet lda.res.w = lda(getStdWavelet(shape),getMasterlist(shape)$pop,CV=TRUE) ct.w = table(getMasterlist(shape)$pop,lda.res.w$class) diag(prop.table(ct.w, 1)) # Total percent correct sum(diag(prop.table(ct.w))) cap.res = capscale(getStdWavelet(shape) ~ getMasterlist(shape)$pop) anova(cap.res) #Classifier on canoncial values lda.res.w = lda(scores(cap.res)$sites,getMasterlist(shape)$pop,CV=TRUE) ct.w = table(getMasterlist(shape)$pop,lda.res.w$class) diag(prop.table(ct.w, 1)) # Total percent correct sum(diag(prop.table(ct.w))) #----------------------------------------- # Section 2: Creating a shapeR object from image files # The following example requires the user to download an archive of JPEG # files from https://github.com/lisalibungan/shapeR/ # place the ShapeAnalysis directory inside the working directory. shape = shapeR("~/ShapeAnalysis/","FISH.csv") shape = detect.outline(shape,write.outline.w.org = TRUE) shape = generateShapeCoefficients(shape) shape = enrich.master.list(shape) ## End(Not run)
Show the project.path and info.file, the number of outlines that have been read and which fundamental methods have been run.
## S4 method for signature 'shapeR' show(object)
## S4 method for signature 'shapeR' show(object)
object |
a shapeR oject |
A function which displayes the outlines which were extracted from the image in the "Fixed" folder on top of the corresponding image in the "Original" folder.
show.original.with.outline(object, folder, fname)
show.original.with.outline(object, folder, fname)
object |
A |
folder |
The folder name where the image is stored |
fname |
Image file name. Not including the extension ".jpg" |
Lisa Anne Libungan
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
## Not run: #Follow the example in Libungan and Palsson (2015) and run the following lines: show.original.with.outline(shape,"IC","403_2") ## End(Not run)
## Not run: #Follow the example in Libungan and Palsson (2015) and run the following lines: show.original.with.outline(shape,"IC","403_2") ## End(Not run)
Remove high frequency pixel noise around the otolith outline
smoothout(object, n)
smoothout(object, n)
object |
A |
n |
The number of iterations. The default value is 100. |
Lisa Anne Libungan
Haines, A.J., Crampton, J.S. (2000). Improvements to the method of Fourier shape analysis as applied in morphometric studies. Palaeontology 43: 765-783.
Claude, J. (2008) Morphometrics with R. Springer. 316 p.
## Not run: data(shape) shape = smoothout(shape,n=100) # Plot smoothed outline on top of original outline for comparison [email protected][["IC"]][["403_2"]] [email protected][["IC"]][["403_2"]] plot(outline.org$X,outline.org$Y,type='l',xlab="",ylab="",lwd=2,axes=F) lines(outline$X,outline$Y,col="red",lwd=2) legend("bottomleft",c('Original','Smoothed'),lty=1,col=c('black','red'),lwd=2) ## End(Not run)
## Not run: data(shape) shape = smoothout(shape,n=100) # Plot smoothed outline on top of original outline for comparison outline.org=shape@outline.list.org[["IC"]][["403_2"]] outline=shape@outline.list[["IC"]][["403_2"]] plot(outline.org$X,outline.org$Y,type='l',xlab="",ylab="",lwd=2,axes=F) lines(outline$X,outline$Y,col="red",lwd=2) legend("bottomleft",c('Original','Smoothed'),lty=1,col=c('black','red'),lwd=2) ## End(Not run)
Function to standardized the wavelet and Fourier coefficients for a specific parameter such as the fish length. For each country/population a regression coefficient is calculated as a function of fish length. If the slope is significantly different from zero, a correction is made according to Lleonart et al 2000. First ANCOVA is performed: variable ~ pop*length_cm, following a method by Longmore et al 2010. If there is a significant interaction between population and length_cm, then the coefficients are not used and automatically discarded. If there is no interaction, the coefficients are kept and standardized with regards to fish length.
stdCoefs(object, classes=NA, std.by, std.type = "mean", p.crit = 0.05,bonferroni= FALSE)
stdCoefs(object, classes=NA, std.by, std.type = "mean", p.crit = 0.05,bonferroni= FALSE)
object |
A |
classes |
The classes to be grouped for standardization. Should be the same as used for the statistical tests |
std.by |
The parameter to be used for standardization. Typically the length of the fish from the master.list. |
std.type |
The tuning of the standardization. The standardization can be sensitive to what value all the fishes are standardized to. Possible values are:
|
p.crit |
An argument used to select the threshold critera for omitting coefficients which show interaction with fish length. If p.crit = 0.05, all coefficients which have p<0.05 are omitted. If p.crit = 0.01, only coefficients with p<0.01 are omitted. |
bonferroni |
A logical parameter for performing Bonferroni for multiple testing |
Lisa Anne Libungan
Lleonart, J., Salat, J. & Torres, G.J. (2000) Removing allometric effects of body size in morphological analysis. Journal of Theoretical Biology, 205, 85-93.
Longmore, C., Fogarty, K., Neat, F., Brophy, D., Trueman, C., Milton, A. & Mariani, S. (2010) A comparison of otolith microchemistry and otolith shape analysis for the study of spatial variation in a deep-sea teleost, Coryphaenoides rupestris. Environmental Biology of Fishes, 89, 591-605.
Reist, J.D. (1985) An Empirical-Evaluation of Several Univariate Methods That Adjust for Size Variation in Morphometric Data. Canadian Journal of Zoology-Revue Canadienne De Zoologie, 63, 1429-1439.
data(shape) shape = stdCoefs(shape,classes="pop","length_cm")
data(shape) shape = stdCoefs(shape,classes="pop","length_cm")
A function which writes the outlines which were extracted from the images in the folder "Fixed" on top of the corresponding images in the "Original" folder. Viewing the resulted images in the folder "Original_with_outlines" is a good quality check to ensure the correct outline has been extracted. If the outline is not correct, then the image can be fixed in an image software, such as GIMP (www.gimp.org), placed in the "Fixed" folder and then the detect.outline
step is repeated.
The function detect.outline
calls this function if the parameter write.outline.w.org
is set to TRUE
.
write.image.with.outline(object, folder = NA, fname = NA, doProgress = T)
write.image.with.outline(object, folder = NA, fname = NA, doProgress = T)
object |
A |
folder |
The folder name where the image is stored |
fname |
Image file name. Not including the extension ".jpg" |
doProgress |
If TRUE, a progressbar is shown |
Lisa Anne Libungan
Libungan LA and Palsson S (2015) ShapeR: An R Package to Study Otolith Shape Variation among Fish Populations. PLoS ONE 10(3): e0121102. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0121102
## Not run: #Use test data from Libungan and Palsson (2015) and run the following lines: shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape,write.outline.w.org = FALSE) write.image.with.outline(shape) ## End(Not run)
## Not run: #Use test data from Libungan and Palsson (2015) and run the following lines: shape = shapeR("ShapeAnalysis/","FISH.csv") shape = detect.outline(shape,write.outline.w.org = FALSE) write.image.with.outline(shape) ## End(Not run)