Problem: bgen, missing-code, and error in temporary.psam

66 views
Skip to first unread message

Hope Lancaster

unread,
Jun 30, 2023, 4:49:40 PM6/30/23
to plink2-users
Hello!
I am trying to rerun (update) my analyses after reviewer responses. It has been a few years since I had to touch these files/code and I am running into problems that I did not have back in 2018 with the bgen files from ALSPAC. Specifically, that the temporary.psam file is created PLINK2 throughs an error. I have pasted log information below of a successful test run (exclude the --missing-code flag) and one of the unsuccessful test runs (include --missing-code). Multiple test runs helped me narrow down the problem to the --missing-code flag. I did get to --freq to run with both flags 1x when I used a sample file where all the phenotype data was missing.

I do need to include the --missing-code flag and the --keep unrelated_children.txt flag. Thanks!

#SUCCESSFUL TEST RUN
plink2 --bgen data_chr22.bgen ref-first --sample dataFac4.sample --keep unrelated_children.txt --freq --out testb
PLINK v2.00a3 SSE4.2 (18 Feb 2022)             www.cog-genomics.org/plink/2.0/
(C) 2005-2022 Shaun Purcell, Christopher Chang   GNU General Public License v3
Logging to testb.log.
Options in effect:
  --bgen data_chr22.bgen ref-first
  --freq
  --keep unrelated_children.txt
  --out testb
  --sample dataFac4.sample

Start time: Fri Jun 30 15:12:27 2023
32018 MiB RAM detected; reserving 16009 MiB for main workspace.
Using up to 4 compute threads.
--bgen: 365644 variants detected, format v1.2.
8941 samples imported from .sample file to testb-temporary.psam .
--bgen: testb-temporary.pgen + testb-temporary.pvar written.
8941 samples (4361 females, 4580 males; 2642 founders) loaded from
testb-temporary.psam.
365644 variants loaded from testb-temporary.pvar.
1 quantitative phenotype loaded (4003 values).
--keep: 7977 samples remaining.
7977 samples (3885 females, 4092 males; 2366 founders) remaining after main
filters.
3647 quantitative phenotype values remaining after main filters.
Calculating allele frequencies... done.
--freq: Allele frequencies (founders only) written to testb.afreq .
End time: Fri Jun 30 15:12:39 2023

#UNSUCCESSFUL TEST RUN(S)
#1 ADD MISSING-CODE -9 WITH KEEP UNRELATED_CHILDREN
plink2 --bgen data_chr22.bgen ref-first --sample dataFac4.sample --missing-code -9 --keep unrelated_children.txt --freq --out testc
PLINK v2.00a3 SSE4.2 (18 Feb 2022)             www.cog-genomics.org/plink/2.0/
(C) 2005-2022 Shaun Purcell, Christopher Chang   GNU General Public License v3
Logging to testc.log.
Options in effect:
  --bgen data_chr22.bgen ref-first
  --freq
  --keep unrelated_children.txt
  --missing-code -9
  --out testc
  --sample dataFac4.sample

Start time: Fri Jun 30 15:13:30 2023
32018 MiB RAM detected; reserving 16009 MiB for main workspace.
Using up to 4 compute threads.
--bgen: 365644 variants detected, format v1.2.
8941 samples imported from .sample file to testc-temporary.psam .
--bgen: testc-temporary.pgen + testc-temporary.pvar written.
Error: Line 4 of testc-temporary.psam has fewer tokens than expected.
End time: Fri Jun 30 15:13:42 2023

Hope Lancaster

unread,
Jun 30, 2023, 4:54:02 PM6/30/23
to plink2-users
my understanding from plink2 documentation is that --missing-code needs to be specified if it isn't NA. but maybe I'm misunderstanding and I don't need to add the --missing-code flag

Christopher Chang

unread,
Jun 30, 2023, 5:01:42 PM6/30/23
to plink2-users
Please rerun with a newer plink2 build; the version history lists the following for 24 Oct 2022: "Fixed a bug that prevented VCF/.bgen import from erroring out properly when sample ID import failed."

Hope Lancaster

unread,
Jul 3, 2023, 1:10:15 PM7/3/23
to plink2-users
hi chris - ok i tried with plink v2.00a4.4LM AVX2 Intel (21 Jun 2023) and got the same error "Line 4 of temp.psam has fewer tokens than expected"

Hope Lancaster

unread,
Jul 3, 2023, 1:25:43 PM7/3/23
to plink2-users
i'm starting to think I don't need the --missing-code flag. the commands run without it and have the correct number of samples / phenotype values when I leave it out.

Christopher Chang

unread,
Jul 3, 2023, 1:27:45 PM7/3/23
to plink2-users
Possibly true, but if you're correct about this error occurring with the latest plink2 build, it's a bug that should be fixed regardless.  Can you post a set of files I can use to reproduce the error?  Feel free to e.g. use qctool to first filter the .bgen down to a single SNP.

Hope Lancaster

unread,
Jul 3, 2023, 1:35:40 PM7/3/23
to plink2-users
I will put it on my todo list. Making the bug report will take some time because I will need to create a dummy sample file since I do not have permission from ALSPAC to share that

Christopher Chang

unread,
Jul 3, 2023, 1:43:21 PM7/3/23
to plink2-users
Alternatively, I can post a sequence of debug build(s) for you to run, and you can send me .log excerpt(s)?  This bug does not sound like it will take a long time to track down in this manner.

Hope Lancaster

unread,
Jul 3, 2023, 2:26:25 PM7/3/23
to plink2-users
that is easier

Christopher Chang

unread,
Jul 3, 2023, 4:45:16 PM7/3/23
to plink2-users
Debug build is posted to https://s3.amazonaws.com/plink2-assets/plink2_linux_avx2_20230703a.zip ; try running your failing command with the --debug flag added.

Christopher Chang

unread,
Jul 3, 2023, 5:00:41 PM7/3/23
to plink2-users
(Debug-build code is also on GitHub, if you want to build from source.  Feel free to mask out any personally-identifying information in the .log.)

Hope Lancaster

unread,
Jul 7, 2023, 3:57:08 PM7/7/23
to plink2-users
let me know if you need more. 
Lancaster_plink2_debug_report.txt

Chris Chang

unread,
Jul 7, 2023, 4:51:43 PM7/7/23
to Hope Lancaster, plink2-users
Thanks.  Bugfix is now posted; let me know if you still have any problems.

--
You received this message because you are subscribed to the Google Groups "plink2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plink2-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plink2-users/2b6e194c-86a8-4aa1-8b57-8e44e7d488b8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages