Subset Fixed Effect Inferred Terms
subsetFixEffectInferred.Rd
This function subsets the tidy TMB object to extract the fixed effect inferred terms along with their categorization into interaction and non-interaction terms.
Value
A list with two elements:
- fixed_term
A list with two components -
nonInteraction
andinteraction
, containing the names of the fixed effect inferred terms categorized as non-interaction and interaction terms, respectively.- data
A data frame containing the subset of tidy_tmb that contains the fixed effect inferred terms.
Examples
input_var_list <- init_variable()
#> Variable name should not contain digits, spaces, or special characters.
#> If any of these are present, they will be removed from the variable name.
mock_data <- mock_rnaseq(input_var_list, 10, 2, 2)
#> Building mu_ij matrix
#> INFO: 3 genes have all(mu_ij) < 1, indicating very low counts. Consider removing them for future analysis using prepareData2fit with row_threshold = 10. To detect them in future experiment, try increasing sequencing depth.
#> k_ij ~ Nbinom(mu_ij, dispersion)
#> Counts simulation: Done
getData2computeActualFixEffect(mock_data$groundTruth$effect)
#> $categorical_vars
#> [1] "label_myVariable"
#>
#> $data
#> logQij_mean geneID label_myVariable
#> 1 -0.21939355 gene1 myVariable1
#> 2 -0.07650958 gene10 myVariable1
#> 3 -0.07440024 gene2 myVariable1
#> 4 -0.14203778 gene3 myVariable1
#> 5 0.65985327 gene4 myVariable1
#> 6 0.17237846 gene5 myVariable1
#> 7 -0.04701527 gene6 myVariable1
#> 8 0.26400485 gene7 myVariable1
#> 9 -0.29151302 gene8 myVariable1
#> 10 -0.06407246 gene9 myVariable1
#> 11 0.12325653 gene1 myVariable2
#> 12 0.08816353 gene10 myVariable2
#> 13 -0.03715441 gene2 myVariable2
#> 14 -0.09440288 gene3 myVariable2
#> 15 0.14988639 gene4 myVariable2
#> 16 -0.39895007 gene5 myVariable2
#> 17 0.15049336 gene6 myVariable2
#> 18 -0.03270347 gene7 myVariable2
#> 19 0.03114311 gene8 myVariable2
#> 20 -0.21287183 gene9 myVariable2
#>
data2fit = prepareData2fit(countMatrix = mock_data$counts, metadata = mock_data$metadata )
#-- fit data
resFit <- fitModelParallel(formula = kij ~ myVariable ,
data = data2fit, group_by = "geneID",
family = glmmTMB::nbinom2(link = "log"), n.cores = 1)
#> Log file location: /tmp/RtmpS86cq0/htrfit.log
#> CPU(s) number : 1
#> Cluster type : PSOCK
tidy_tmb <- tidy_tmb(resFit)
subsetFixEffectInferred(tidy_tmb)
#> $fixed_term
#> $fixed_term$nonInteraction
#> [1] "myVariable2"
#>
#> $fixed_term$interaction
#> character(0)
#>
#>
#> $data
#> ID effect component group term estimate std.error
#> 1 gene1 fixed cond NA (Intercept) -4.316869e-08 7.071068e-01
#> 2 gene1 fixed cond NA myVariable2 -1.828676e+01 5.135364e+03
#> 3 gene10 fixed cond NA (Intercept) -1.900518e+01 6.708576e+03
#> 4 gene10 fixed cond NA myVariable2 1.969833e+01 6.708576e+03
#> 5 gene2 fixed cond NA (Intercept) -1.448419e-08 7.071070e-01
#> 6 gene2 fixed cond NA myVariable2 4.054652e-01 9.128709e-01
#> 7 gene3 fixed cond NA (Intercept) -6.931258e-01 9.999892e-01
#> 8 gene3 fixed cond NA myVariable2 -3.454563e-05 1.414211e+00
#> 9 gene4 fixed cond NA (Intercept) 3.187481e-08 7.071238e-01
#> 10 gene4 fixed cond NA myVariable2 1.970834e-08 1.000024e+00
#> 11 gene5 fixed cond NA (Intercept) -1.838388e-07 7.071053e-01
#> 12 gene5 fixed cond NA myVariable2 -1.376700e-07 9.999981e-01
#> 13 gene6 fixed cond NA (Intercept) 4.054650e-01 7.188588e-01
#> 14 gene6 fixed cond NA myVariable2 -1.098612e+00 1.303910e+00
#> 15 gene7 fixed cond NA (Intercept) 4.054651e-01 5.773789e-01
#> 16 gene7 fixed cond NA myVariable2 -4.054651e-01 9.128918e-01
#> 17 gene8 fixed cond NA (Intercept) -1.824920e+01 5.082121e+03
#> 18 gene8 fixed cond NA myVariable2 1.824920e+01 5.082122e+03
#> 19 gene9 fixed cond NA (Intercept) -6.931469e-01 9.999998e-01
#> 20 gene9 fixed cond NA myVariable2 -2.239913e+01 5.169240e+04
#> statistic p.value
#> 1 -6.104974e-08 1.0000000
#> 2 -3.560948e-03 0.9971588
#> 3 -2.832968e-03 0.9977396
#> 4 2.936291e-03 0.9976572
#> 5 -2.048373e-08 1.0000000
#> 6 4.441648e-01 0.6569234
#> 7 -6.931332e-01 0.4882259
#> 8 -2.442750e-05 0.9999805
#> 9 4.507671e-08 1.0000000
#> 10 1.970786e-08 1.0000000
#> 11 -2.599878e-07 0.9999998
#> 12 -1.376702e-07 0.9999999
#> 13 5.640398e-01 0.5727271
#> 14 -8.425516e-01 0.3994793
#> 15 7.022513e-01 0.4825225
#> 16 -4.441546e-01 0.6569308
#> 17 -3.590862e-03 0.9971349
#> 18 3.590862e-03 0.9971349
#> 19 -6.931470e-01 0.4882173
#> 20 -4.333157e-04 0.9996543
#>