Skip to content

Implementing msqrobRefit() #68

@cvanderaa

Description

@cvanderaa

We need a function that allows the user to fit a simpler model for proteins that lead to a fitError.

Here is a tentative implementation for msqrobRefit():

msqrobRefit <- function(object, formula, i, subset, fcol, name, 
                        modelColumnName, ...) {
    seti <- getWithColData(object, i)
    setj <- getWithColData(object, name)
    if (any(!subset %in% rowData(seti)[[fcol]]))
        stop("Some entries in 'subset' not found in '", fcol, 
             "' (rowData of set '", i, "')")
    setjRefit <- msqrobAggregate(
        seti[rowData(seti)[[fcol]] %in% subset, ],
        formula = formula, fcol = fcol, modelColumnName = modelColumnName,
        ...
    )
    rowData(setj)[[modelColumnName]][subset] <- 
        rowData(setjRefit)[[modelColumnName]][subset]
    modelsNew <- rowData(setj)[[modelColumnName]]
    hlp <- limma::squeezeVar(
        var = vapply(modelsNew, getVar, numeric(1)),
        df = vapply(modelsNew, getDF, numeric(1))
    )
    for (ii in seq_along(modelsNew)) {
        modelsNew[[ii]]@varPosterior <- as.numeric(hlp$var.post[ii])
        modelsNew[[ii]]@dfPosterior <- as.numeric(hlp$df.prior + getDF(modelsNew[[ii]]))
    }
    rowData(object[[name]])[[modelColumnName]] <- modelsNew
    object
}

We need to think carefully about this. How can a user retrieve the information about which features has been fit with which
model? We should provided a helper/getter/show function(s) that provides streamlined access to that piece of info.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions