Skip to content

Commit

Permalink
add imageMat
Browse files Browse the repository at this point in the history
  • Loading branch information
timflutre committed Oct 19, 2024
1 parent 98ff15e commit de60387
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^.*\.Rproj$
^\.Rproj\.user$
^misc$
^.*\.o$
^.*\.so$
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Depends:
data.table,
lme4,
Matrix,
methods,
Rcpp,
stats
License: GPL-3 | AGPL-3
Expand Down Expand Up @@ -55,7 +56,6 @@ Suggests:
lmerTest,
loo,
MASS,
methods,
MuMIn,
nlme,
pdftools,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export(h2v2WX2019)
export(haplosAlleles2num)
export(haplosList2Matrix)
export(hinton)
export(imageMat)
export(imageWithScale)
export(imputeGenosWithMean)
export(imputeGenosWithMeanPerPop)
Expand Down Expand Up @@ -311,3 +312,4 @@ import(Rcpp)
import(data.table)
import(lme4)
import(stats)
importFrom(methods,is)
1 change: 1 addition & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
##' @import data.table
##' @import lme4
##' @import Matrix
##' @importFrom methods is
##' @import Rcpp
##' @import stats

Expand Down
19 changes: 19 additions & 0 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,25 @@ hinton <- function(m, main="", max.sqrt.m=NULL){
on.exit(graphics::par(def.par))
}

##' Image of a matrix
##'
##' Plots an image of a matrix.
##' @param mat matrix
##' @param title optional title of the plot
##' @param col colors
##' @return nothing
##' @author Timothee Flutre
##' @export
imageMat <- function(mat, title,
col=grDevices::grey.colors(length(table(c(mat))), rev=TRUE)){
if(missing(title)){
title <- deparse(substitute(mat))
title <- paste0(title, " (", nrow(mat), " x ", ncol(mat), ")")
}
graphics::image(t(mat)[,nrow(mat):1], axes=FALSE, main=title,
col=col)
}

##' Plot a scale, e.g. to add on the side of image()
##'
##' Takes some time to draw (there is one polygon per break...)
Expand Down
1 change: 1 addition & 0 deletions R/stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ rmsre <- function(rel_error){
##' Returns the relative root mean squared error (RRMSE) as defined in \href{https://doi.org/10.3354/cr030079}{Willmott and Matsuura (2005)}.
##' @param error vector \eqn{(\hat{\theta}_i - \theta_i)}
##' @param theta vector \eqn{\theta_i}
##' @param perc if TRUE, the return value will be a percentage
##' @return numeric
##' @author Timothee Flutre
##' @seealso \code{\link{rmse}}, \code{\link{rmsre}}
Expand Down
28 changes: 28 additions & 0 deletions man/imageMat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/matWide2Long.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/rrmse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions misc/intro-het-GxE.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ suppressPackageStartupMessages(library(emmeans))
suppressPackageStartupMessages(library(lme4))
suppressPackageStartupMessages(library(nlme))
suppressPackageStartupMessages(library(MM4LMM))
suppressPackageStartupMessages(library(MegaLMM))
```

Execution time (see the appendix):
Expand Down Expand Up @@ -830,6 +831,12 @@ cor(tmp[,"true"], tmp[,"estim"])
plot(tmp[,"estim"], tmp[,"true"], las=1, asp=1, xlab="estimated value", ylab="true value", main="Error variances (gls het)", pch=19); abline(a=0, b=1, lty=2)
```

### `MegaLMM`

Details: https://github.com/deruncie/MegaLMM/blob/master/vignettes/MultiEnvironmentTrial.Rmd

TODO

### `MMEst` from `MM4LMM`

The `MMEst` from the `MM4LMM` package performs inference via ReML, and can handle both random variables and heteroscedasticity.
Expand Down

0 comments on commit de60387

Please sign in to comment.