Package 'mvngGrAd'

Title: Moving Grid Adjustment in Plant Breeding Field Trials
Description: Package for moving grid adjustment in plant breeding field trials.
Authors: Frank Technow
Maintainer: Frank Technow <[email protected]>
License: GPL (>= 2)
Version: 0.1.6
Built: 2024-10-31 20:53:09 UTC
Source: CRAN

Help Index


R Package mvngGrAd: Moving Grid Adjustment In Plant Breeding Field Trials

Description

The mvngGrAd package allows to perform a moving grid adjustment in plant breeding field trials. Please see the included vignette for a more detailed description of the package and the rational behind moving grid adjustment.

Details

Package: mvngGrAd
Type: Package
Version: 0.1.5
Date: 2023-10-09
License: GNU General Public License Version 2, June 1991
LazyLoad: no

The main function, movingGrid, performs the adjustment with a user designed grid. The function sketchGrid helps with designing the grid by plotting its shape. The functions fitted, movingMean and entryData are convenience functions to extract the most relevant information from the object created by movingGrid. The package defines one new class, movG, and provides methods for it for the functions, movingMean, entryData, fitted, summary, show and residuals.

Rdversion

1.1

Author(s)

Frank Technow

Maintainer: Frank Technow [email protected]


Circular extension of the grid

Description

The function finds the subscripts of the cells that extend the grid in layers that extend from the center in all directions other than 0, 90, 180 and 270 degree. The function is not intended to be called by the user.

Usage

circularExtension(i, j, layers, rowLimit, colLimit)

Arguments

i

"integer", row subscript of center cell

j

"integer", column subscript of center cell

layers

"integer", vector giving the layers to be included in the grid that extents from the center cell in all other directions than 0, 90, 180 and 270 degree. Can be NULL ( no extension) and must not contain '0', negative or duplicated values.

rowLimit

"integer", row limit (= number of rows) of the field layout

colLimit

"integer", column limit (= number of columns) of the field layout

Details

This function is called by the function movingGrid and is not intended to be called by the user.

Value

A matrix with the row subscripts of the cells in column one and the column subscripts in column two.

Rdversion

1.1

Author(s)

Frank Technow

Examples

circularExtension(i = 1,
                  j = 10,
                  rowLimit = 50,
                  colLimit = 50,
                  layers = c(1,2,3))

Function to extract entry information

Description

Generic function to extract the most relevant information from the adjustment procedure for each entry included in the trial.

Usage

entryData(object,...)

Arguments

object

an object from the context of moving grid adjustment

...

possible other arguments to methods

Value

returned is a data.frame with the following content

row

the row of the entry

column

the column of the entry

column

the column of the entry

adjustedPhe

the adjusted phenotypic value

observedPhe

the observed phenotypic value

movingMean

the moving mean

nValues

the number of values to calculate the moving mean

... and possibly more

Rdversion

1.1

Author(s)

Frank Technow

See Also

movingGrid (includes example of entryData)


Methods for Function entryData

Description

Methods for function entryData

Methods

object = "movG"

returned is a data.frame with: row, column, adj. phenotypic value, obs. phenotypic value, moving mean, number of values


Vertical and horizontal extension of the grid ('cross shape')

Description

The function finds the subscripts of the cells that extend from the center in 0, 90, 180 and 270 degree direction ('cross shape'). The function is not intended to be called by the user.

Usage

extendHorVer(i, j, shapeCross, rowLimit, colLimit)

Arguments

i

"integer", row subscript of center cell

j

"integer", column subscript of center cell

shapeCross

"list" of length 4, each element contains the cells that are to be included in the grid that extends from the center in 0, 90, 180 and 270 degree direction.

Elements can be NULL (no extension in this direction) and must contain no '0', duplicated or negative values.

shapeCross[[1]]DOWN (180 degree) from the center cell (same column)

shapeCross[[2]]UP (0 degree) from the center cell (same column)

shapeCross[[3]]LEFT (270 degree) from the center cell (same row)

shapeCross[[4]]RIGHT (90 degree) from the center cell (same row)

rowLimit

"integer", row limit (= number of rows) of the field layout

colLimit

"integer", column limit (= number of columns) of the field layout

Details

This function is called by the function movingGrid and is not intended to be called by the user.

Value

A matrix with the row subscripts of the cells in column one and the column subscripts in column two.

Rdversion

1.1

Author(s)

Frank Technow

Examples

shape <- list(c(1,2,3),
              c(1,2,3),
              c(1:5),
              c(1:5))

extendHorVer(i = 25,
             j = 25,
             shapeCross = shape,
             rowLimit = 50,
             colLimit = 50)

Methods for Function fitted in Package "stats"

Description

Methods for function fitted in Package "stats"

Methods

object = "ANY"

default method, the S3 generic

object = "movG"

Returns a vector with the adjusted values.


Class "movG"

Description

The "movG" Class Represents Objects From A Moving Grid Adjustment Using A Designed Grid

Rdversion

1.1

Objects from the Class

Objects can be created by calls of the form new("movG", ...) or by a call to function movingGrid.

Slots

movingMeanMap:

Object of class "matrix" for the moving mean of the cell in the ith row and jth column.

row:

Object of class "integer" for the row subscripts.

col:

Object of class "integer" for the column subscripts.

observedPhe:

Object of class "numeric" for the observed phenotypic values.

adjustedPhe:

Object of class "numeric" for the adjusted phenotypic values.

movingMean:

Object of class "numeric" for the moving means.

nValues:

Object of class "integer" for the number of non-NA values used for calculating the moving mean.

adjModel:

Object of class "lm" for the model used for covariate adjustment.

correlation:

Object of class "numeric" for the coefficient of correlation between the moving means and the observed phenotypic values.

maxValues:

Object of class "integer" for the maximum number of values possible given the design of the grid or the number of nearest neighbors.

FunCall:

Object of class "call" for the function call.

Methods

entryData

signature(object = "movG"): extract all relevant information on each entry from the object

movingMean

signature(object = "movG"): extract only the moving means from the object

fitted

signature(object = "movG"): extract only the adjusted phenotypical values

residuals

signature(object = "movG"): extract the residuals from the model for calculation of the regression coefficient

show

signature(object = "movG"): show some summary statistics and informations

summary

signature(object = "movG"): same as show, but with a list of the summarized values invisibly returned

Note

The data in the slots observedPhe, adjustedPhe, movingMean, and nValues must correspond.

Author(s)

Frank Technow

See Also

movingGrid

Examples

showClass("movG")

Moving Grid Adjustment In Plant Breeding Field Trials

Description

The function uses the phenotypic information from plants or plots (entries) in a designed grid to obtain an adjusted (for environmental variation) phenotypic value of the entry in the center of the grid. The adjustment is done by calculating the mean of all the entries included and using it as a covariate.

Usage

movingGrid(rows, columns, obsPhe, shapeCross, layers, excludeCenter = TRUE)

Arguments

rows

An integer vector with the row subscripts of the phenotypic values to be adjusted.

columns

An integer vector with the column subscripts of the phenotypic values to be adjusted.

obsPhe

A numeric vector with the observed phenotypic values of the entries that are to be adjusted. The arguments to rows, columns and obsPhe must, of course, correspond.

shapeCross

"list" of length 4, each element contains the cells that are to be included in the grid that extends from the center in 0, 90, 180 and 270 degree direction.

Elements can be NULL (no extension in this direction) and must contain no '0', duplicated or negative values.

shapeCross[[1]]DOWN (180 degree) from the center cell (same column)

shapeCross[[2]]UP (0 degree) from the center cell (same column)

shapeCross[[3]]LEFT (270 degree) from the center cell (same row)

shapeCross[[4]]RIGHT (90 degree) from the center cell (same row)

layers

"integer", vector giving the layers to be included in the grid that extents from the center cell in all directions other than 0, 90, 180 and 270 degree. Can be NULL ( no extension) and must not contain '0', negative or duplicated values.

excludeCenter

Should the center entry (the one which is adjusted) be excluded from the calculation of the moving mean, logical TRUE (default) or FALSE.

Details

Please see the included vignette for a more detailed description of the rational underlining the adjustment procedure and usage of the function.

The function movingGrid calls the functions extendHorVer and extendCircular to form the grid (i.e. determine the row and column subscripts of the cells included). These two functions are not intended to be called by the user.

Value

An object of class "movG". See movG-class for details.

Rdversion

1.1

Note

The field layout is always assumed to be a rectangular matrix with max(rows) * max(columns) cells! All of the cells that were not mentioned in arguments rows and columns are NA.

If, for example, the last row was only planted with half the number of entries as the other rows, the other half of the row will consist of cells with NA values.

These NA values are ignored by movingGrid and the various extractor functions. They do not influence the results of movingGrid.

The general linear model, that is part of the adjustment procedure, is fit via the function lm.

Author(s)

Frank Technow

See Also

sketchGrid, entryData, movG, mvngGrAd-package

Examples

### data creation ###
#####################


### The field plan consists of 50 rows and 50 columns
### (= 2500 cells = 2500 entries)

## row vector

rows <- rep(1:50,each=50)


## column vector
cols <- rep(1:50,50)

## simulation of growing conditions with a horizontal gradient between
## the rows and some random noise within

set.seed(666)
growingCond <- rep(1:50,each=50) + rnorm(2500)

## simulation of the genotypic effects
gEffects <- rnorm(2500,mean=0,sd=5)

## observed phenotypic values
yield <- growingCond + gEffects

## adjustment with movingGrid

cross <- list(c(1),
              c(1),
              c(1:4),
              c(1:4))

exampleResults <- movingGrid(rows = rows,
                             columns = cols,
                             obsPhe = yield,
                             shapeCross = cross,
                             layers = c(1,2),
                             excludeCenter = TRUE)

## a summary

summary(exampleResults)

## the adjusted phenotypic values of the first 25 entries

fitted(exampleResults)[1:25]

## all information on entry, for the first 25

entryData(exampleResults)[1:25,]

## moving means for the first 25

movingMean(exampleResults)[1:25]

Function to extract the moving means from the object

Description

Generic function to extract the moving means, which are used as covariates, from the object.

Usage

movingMean(object,...)

Arguments

object

an object from the context of moving grid adjustment

...

possible other arguments to methods

Value

returned is a vector with the moving means

Rdversion

1.1

Author(s)

Frank Technow

See Also

movingGrid (includes example of movingMean)


Methods for Function movingMean

Description

Methods for function movingMean

Methods

object = "movG"

returns a vector with the moving means


Methods for Function residuals in Package ‘stats’

Description

Methods for function residuals in Package ‘stats’

Methods

object = "ANY"

default method, the S3 generic

object = "movG"

Residuals from the model to calculate the regression coefficient for adjustment by the covariate


Methods for Function show in Package ‘methods’

Description

Methods for function show in Package ‘methods’

Methods

object = "movG"

Some summary statistics and informations are calculated from the object and printed.


Function to aid with grid design

Description

The function aids with grid design by plotting the designed grid.

Usage

sketchGrid(i, j, rowLimit, colLimit, layers, shapeCross, excludeCenter,...)

Arguments

i

"integer", row subscript of center cell

j

integer value, giving the column of the center cell

rowLimit

"integer", row limit (= number of rows) of the field layout

colLimit

"integer", column limit (= number of columns) of the field layout

layers

"integer", vector giving the layers to be included in the grid that extents from the center cell in all other directions than 0, 90, 180 and 270 degree. Can be NULL ( no extension) and must not contain '0', negative or duplicated values.

shapeCross

"list" of length 4, each element contains the cells that are to be included in the grid that extends from the center in 0, 90, 180 and 270 degree direction.

Elements can be NULL (no extension in this direction) and must contain no '0', duplicated or negative values.

shapeCross[[1]]DOWN (180 degree) from the center cell (same column)

shapeCross[[2]]UP (0 degree) from the center cell (same column)

shapeCross[[3]]LEFT (270 degree) from the center cell (same row)

shapeCross[[4]]RIGHT (90 degree) from the center cell (same row)

excludeCenter

Should the center entry (the one which is adjusted) be included in the calculation of the moving mean, logical TRUE (default) or FALSE.

...

further arguments passed to or from other methods

Details

When using the function movingGrid, this function can be used to look at different designs, to see how many and which cells are included when the center cell is close to the edge of the field layout, and for verifying that the actual arguments to shapeCross and layers really specify the intended design.

sketchGrid is a generic function with currently one method for sketching a designed grid (as needed for function movingGrid). The method is dispatched when the arguments shapeCross and layers are given (with class "ANY").

Value

A plot is created (via a call to function plot from the traditional R graphics system).

Rdversion

1.1

Author(s)

Frank Technow

See Also

movingGrid

Examples

## with method for designed grid

sketchGrid(25,
           25,
           shapeCross = list(c(1:4,7),
             c(1:4,7),
             c(1:4,7),
             c(1:4,7)),
           layers = c(1,2,3,5,6),
           excludeCenter = TRUE,
           rowLimit = 50,
           colLimit = 50)

Methods for Function sketchGrid in Package "mvngGrAd"

Description

Methods for function sketchGrid in Package "mvngGrAd"

Methods

objects:

i = "ANY", j = "ANY", rowLimit = "ANY",colLimit = "ANY",

layers = "ANY", shapeCross = "ANY",

excludeCenter = "ANY"

Method to sketch designed grid, for example for usage with function movingGrid.


Methods for Function summary in Package "base"

Description

Methods for function summary in Package "base"

Methods

object = "ANY"

default method, the S3 generic

object = "movG"

Identical to method for function show, except that a list with the summarized values is invisibly returned. An additional argument (showSummary with default value TRUE) is added. If set to FALSE, the summary is not printed, only the list is invisibly returned.