Skip to content

Enable group-level weight specification in flm_def constrast construction #39

Description

@lianos

You can combine multiple groups in the numer or denom when constructing a linear model.

Currently it gives each group within the numer/denom equal weight, but you may want to adjust that.

Using the example tcga dataset, we can compare stage1 and stage2 vs stage3 and stage4 tumors like so:

library(FacileAnalysis)
library(FacileData)

efds <- exampleFacileDataSet()
es <- filter_samples(efds, indication == "BLCA", sample_type == "tumor")

flm.equal <- flm_def(es, "stage", numer = c("I", "II"), denom = c("III", "IV"))

That would construct a contrast vector that compares the average of stage I and II vs the average of stage III and IV, like so:

   I   II  III   IV 
 0.5  0.5 -0.5 -0.5 

But what if you wanted something like this?

    I    II  III   IV 
 0.75  0.25 -0.5 -0.5 

Potential Syntax

Option 1

The names of the numer/denom character vectors could be the group names, and the values could be the fractional weights:

flm.weighted <- flm_def(es, numer = c("I" = 0.75, "II" = 0.25), denom = c("III", "IV"))

This would require us to check the numer/denom vectors to see if they were numeric or character first, and then pull the names of the groups and their weights from the appropriate.

Option 2

Or vice versa? This way may require less (code) hacking, but I'm not the biggest fan of havig numbers for names() of a vector

flm.weighted <- flm_def(es, numer = c("0.75" = "I", "0.25" = "II"), denom = c("III", "IV"))

Option 3

You could imagine having a separate parameter for group weights, but ...

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions