Updating chr using plink2

597 views
Skip to first unread message

hengameh shams

unread,
Feb 20, 2021, 4:09:04 AM2/20/21
to plink2-users
Hello,

I need to update chromosome numbers in bgen files (all have been set to zero), but the '--update-chr' flag seems to be obsolete in plink2. Is there any other way to do this?

Thanks,
Hengameh

Christopher Chang

unread,
Feb 20, 2021, 11:52:43 AM2/20/21
to plink2-users
Did you try using the 'snpid-chr' modifier with --bgen?

Christopher Chang

unread,
Feb 20, 2021, 12:29:43 PM2/20/21
to plink2-users
(Meanwhile, --update-chr is not "obsolete", it'll be added at some point.  It just hasn't been a priority because (i) it's rarely needed on plink2-specific data, and (ii) it's not difficult to emulate with a short script operating on the .pvar file.)

On Saturday, February 20, 2021 at 1:09:04 AM UTC-8 hengame...@gmail.com wrote:

Hengameh Shams

unread,
Feb 20, 2021, 3:27:51 PM2/20/21
to Christopher Chang, plink2-users
Thank Christopher. I used 'snpid-chr' but got this error: 

Error: Length-0 SNP ID in .bgen file


I then generated bim files and could see SNP IDs for all variants. The chromosome field is zero.


What's the best way to update chromosomes in bgen files?


--
You received this message because you are subscribed to a topic in the Google Groups "plink2-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/plink2-users/BpQKiiFXymM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to plink2-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plink2-users/43d0c7ea-af9d-4302-a3e5-7b5694377c26n%40googlegroups.com.


--
Hengameh Shams, PhD 
Postdoctoral Fellow, Neurology
Department of Neurology
Weill Institute for Neurosciences
University of California, San Francisco

Christopher Chang

unread,
Feb 20, 2021, 3:36:09 PM2/20/21
to plink2-users
The other relevant import flag is --oxford-single-chr.

Hengameh Shams

unread,
Feb 20, 2021, 4:17:52 PM2/20/21
to Christopher Chang, plink2-users
Got it. Problem solved. Thanks a lot.

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/4833ee6c-4005-47cb-aa86-9961194c7049n%40googlegroups.com.

Lea Lemler

unread,
Apr 14, 2022, 5:19:31 AM4/14/22
to plink2-users
Dear all, 

I have the same issue and I tried to follow your instructions above.

I am able to convert my bgen files with plink2 --bgen crcsurvival_chr21.bgen --sample crcsurvival_chr21.sample --export vcf vcf-dosage=DS to vcf files, but I do get the 0 in the vcf file, which should have the number of the chromosome.

I tried: 

plink2 --bgen crcsurvival_chr21.bgen snpid-chr 21 --sample crcsurvival_chr21.sample --export vcf vcf-dosage=DS

and 

plink2 --bgen crcsurvival_chr21.bgen --sample crcsurvival_chr21.sample --export vcf vcf-dosage=DS --oxford-single-chr 21 


It does create some log, pgen, psam and pvar file, but no vcf file.

Not sure what I am doing wrong, any help very appreciated!

Thank you & Happy Easter,
Lea 

Lea Lemler

unread,
Apr 14, 2022, 9:31:33 AM4/14/22
to plink2-users
I think i got it now with plink2 --bgen crcsurvival_chr21.bgen --oxford-single-chr 21 --sample crcsurvival_chr21.sample --export vcf vcf-dosage=DS/.

Nathalie Smogeli

unread,
Sep 8, 2023, 9:03:20 AM9/8/23
to plink2-users
So update-chr is still not added as a flag to be used to plink2?

Christopher Chang

unread,
Sep 8, 2023, 4:33:11 PM9/8/23
to plink2-users
I went ahead and implemented it in today's build.  Note that you now need to include --sort-vars in the same command.

Abhishek Shakya

unread,
Oct 27, 2023, 3:01:10 AM10/27/23
to plink2-users
May be I am understanding it wrong but is it supposed to update chromosome codes?

I am moving from GRCh37 to GRCh38 and I have to prepend chr to every chromosome. I created a update_chr.txt file as follows:
1 chr1
2 chr2
...
X chrX
Y chrY

I ran the command with --update-chr update_chr.txt but I got same error:
--update-chr: 0 values updated, 108081 variant IDs not present.

I also tried preparing update_chr.txt like this:
chrY Y:56880236:T,.
chrY Y:56880763:A,.
chrY Y:56881428:G,.

but still got same error
--update-chr: 0 values updated, 108081 variant IDs not present.

Am I doing something fundamentally wrong?

Christopher Chang

unread,
Oct 27, 2023, 12:45:11 PM10/27/23
to plink2-users
"1" vs. "chr1" is not related to build 37 vs. build 38; instead it's Ensembl's vs. UCSC's convention.

You're looking for the --output-chr flag.

Abhishek Shakya

unread,
Oct 28, 2023, 6:35:43 AM10/28/23
to plink2-users
Apologies and thanks for correcting me. It is Ensembl's vs UCSC's convention.

I will check out --output-chr flag.


Regards,
Abhishek
Reply all
Reply to author
Forward
0 new messages