Outdated R version in containerized AFNI not able to install necessary packages (e.g. lme4)

AFNI version info (afni -ver): 25.0.03

Hello AFNI experts!

I have been using AFNI on our institutional HPC to preprocess my data. afni_proc.py worked fine, and my data is now ready for analysis. I was hoping to use 3dLMEr to analyze my data.

The AFNI we are using is the Docker container version of AFNI that has been converted into an apptainer container (our HPC does not have Docker but has Apptainer). I built this container with the following command:

apptainer build afni-25.0.03.sif docker://afni/afni_make_build

Again, this containerized version of AFNI worked fine for afni_proc.py, but it is now running into issues trying to run programs that require special R packages, like 3dLMEr. From what I can tell, the version of R that is included in the AFNI container is old (3.4.4), and the required packages like lme4 are apparently "not available for R version 3.4.4". See the 3dLMEr output below:

Checking dataTable file:
FAAHa_dataTable_bev_Feb-07-25.txt

++Good: Table is regular and rectangular.
Read 1902 items

Dimensions: 
rows: 172 | columns: 10

+* Warning: Each "Subj" does not have the same number of "InputFiles"!
Most Subj have 8 InputFiles. The following Subj differ:
 Subj NumInputFiles
 FA06 4            
 FA10 4            
 FA22 4            
 FA28 4            
 FA33 4            

Data summary: 
 Variable  Detected_Type Details                                     
 Subj      Subjects      Num Subjects=24                             
 Session   Categorical   Counts: ALC=88 | PBO=84                     
 Stimulus  Categorical   Unique levels=4                             
 Sex       Quantitative  Min=1 | Max=2 | ? categorical ? Num levels=2
 AUDIT     Quantitative  Min=1 | Max=14 | Num outliers=16            
 AEA       Categorical   Unique levels=37 | ? 36 Numeric levels found
 TwoAG     Categorical   Unique levels=32 | ? 31 Numeric levels found
 STAIS     Quantitative  Min=24 | Max=47                             
 Motion    Quantitative  Min=0 | Max=83 | Num outliers=8             
 InputFile Data          Number of InputFiles=172                    

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

++ Good: All InputFiles are on the same grid.

Warning message:
In readLines(file.in) :
  incomplete final line found on 'FAAHa_dataTable_bev_Feb-07-25.txt'

++++++++++++++++++++++++++++++++++++++++++++++++++++
***** Summary information of data structure *****
172 response values
4 levels for factor Stimulus : alc nonalc shape text 
2 levels for factor Sex : 1 2 
9 levels for factor AUDIT : 1 10 14 2 3 5 6 7 8 
37 levels for factor AEA : 0.046 0.049 0.052 0.068 0.070 0.071 0.076 0.077 0.081 0.083 0.087 0.089 0.094 0.097 0.098 0.101 0.103 0.108 0.111 0.116 0.120 0.122 0.123 0.128 0.135 0.139 0.141 0.142 0.143 0.146 0.155 0.169 0.171 0.180 0.188 0.213 NaN 
32 levels for factor TwoAG : 11.6 12.5 12.7 14.9 15.7 16.3 17.2 17.7 18.3 18.4 19.3 20.6 21.2 21.6 21.7 24.0 26.2 26.7 28.3 28.4 29.0 34.0 34.5 35.3 39.2 4.4 6.6 8.1 8.9 9.0 9.5 NaN 
18 levels for factor STAIS : 24 25 26 27 28 29 30 31 32 33 34 36 37 38 40 41 42 47 
37 levels for factor Motion : 0 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 27 3 30 31 32 33 36 37 4 43 47 5 6 7 8 83 9 
***** End of data structure information *****
++++++++++++++++++++++++++++++++++++++++++++++++++++

Reading input files now...

Reading input files for effect estimates: Done!


Range of input data: [-37.151, 34.673]

If the program hangs here for more than, for example, half an hour,
kill the process because the model specification or something else
is likely inappropriate.

Installing package into ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Loading required package: lme4
Warning messages:
1: package ‘lme4’ is not available (for R version 3.4.4) 
2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘lme4’
Installing package into ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning: dependencies ‘lme4’, ‘ggplot2’, ‘pbkrtest’ are not available
also installing the dependency ‘numDeriv’

trying URL 'http://cloud.r-project.org/src/contrib/numDeriv_2016.8-1.1.tar.gz'
Content type 'application/x-gzip' length 76053 bytes (74 KB)
==================================================
downloaded 74 KB

trying URL 'http://cloud.r-project.org/src/contrib/lmerTest_3.1-3.tar.gz'
Content type 'application/x-gzip' length 195633 bytes (191 KB)
==================================================
downloaded 191 KB

* installing *source* package ‘numDeriv’ ...
** package ‘numDeriv’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (numDeriv)
ERROR: dependencies ‘lme4’, ‘ggplot2’ are not available for package ‘lmerTest’
* removing ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4/lmerTest’

The downloaded source packages are in
	‘/tmp/RtmpMxsbJO/downloaded_packages’
Loading required package: lmerTest
Warning messages:
1: In install.packages(pkgs_miss, dep = TRUE, repos = "http://cloud.r-project.org") :
  installation of package ‘lmerTest’ had non-zero exit status
2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘lmerTest’
Installing package into ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning: dependencies ‘car’, ‘lme4’ are not available
trying URL 'http://cloud.r-project.org/src/contrib/phia_0.3-1.tar.gz'
Content type 'application/x-gzip' length 545361 bytes (532 KB)
==================================================
downloaded 532 KB

ERROR: dependency ‘car’ is not available for package ‘phia’
* removing ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4/phia’

The downloaded source packages are in
	‘/tmp/RtmpMxsbJO/downloaded_packages’
Loading required package: phia
Warning messages:
1: In install.packages(pkgs_miss, dep = TRUE, repos = "http://cloud.r-project.org") :
  installation of package ‘phia’ had non-zero exit status
2: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called ‘phia’
~~~~~~~~~~~~~~~~~~~ Model test failed  ~~~~~~~~~~~~~~~~~~~
Possible reasons:

0) Missing R packages lme4, lmerTest, and phia. 
1) Inappropriate model specification with options -model, or -qVars.

2) Incorrect specifications with -gltCode.

3) inconsistencies in the data table.
4) Inconsistent variable names (e.g., typos, case sensitive characters).

** Error: 
   Quitting due to model test failure...
Job finished with exit code 1 at: Fri Feb  7 15:56:20 MST 2025

I was working with the HPC support people at my institution to try and get it to work but no avail. When I try to run R through the containerized AFNI and manually install the packages I get the same error.

Is there a way to upgrade the version of R that comes with the AFNI docker container? Or is there a way to point the containerized AFNI to use a different version of R that I download myself?

Thanks!

Ryann

Dear Ryann,
I have the same problem,
let us know if you find the solution
Clément

Dear Ryann,
It appears that I found a docker with a recent version of R:
https://hub.docker.com/r/nmuncy/afni_ub24
I just tested and the required R packages seems to be already installed on it,
3dLMEr worked just fine for me

Thank you to however did that =)
Clément

Thanks for the suggestion, hopefully it is able to help some people - unfortunately that version doesn't work well on our HPC.

Do any of the other AFNI experts have any advice on how to update the R version that comes with the containerized version of AFNI? Other relevant info is that the HPC is entirely command line, so I do not have access to RStudio or the GUI, and I am unable to install the R package "installr" since it requires another package called "stringr" which is only available in R 3.6 and greater.

Ryann

R can be run from the command line with no GUI interface with

R --vanilla

Hi Daniel,

I was able to run R through the command line before by doing:

apptainer exec afni-25.0.03.sif R

However, when I try and install the necessary packages (i.e. lme4) this is what happens:

> install.packages('lme4')
Installing package into ‘/home/ryann.tansey/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
Warning message:
package ‘lme4’ is not available (for R version 3.4.4) 

So unfortunately the version of R that is packaged in the container (which I built from the docker container in these instructions, from afni/afni_make_build) does not support lme4 or any of the packages that depend on it. I tried to get around this by installing the "installr" package (which is able to update R version from within the command line) but unfortunately this package also isn't supported on R 3.4.4 haha (looks like it is only compatible on 3.6 and greater). So I am not sure how to get the version of R in this container updated so that it works with the necessary packages for 3dLMEr.

Thanks!

Ryann