opain / Predicting-TWAS-features

Tool for predicting TWAS features (e.g. gene expression) in a target sample
GNU General Public License v3.0
15 stars 2 forks source link

Error in if (n_flip > 0) { : missing value where TRUE/FALSE needed #1

Closed freshfischer closed 3 years ago

freshfischer commented 3 years ago

@opain Hello, it's very kind that you make this algorithms. The Example data could run successfully. But when i replaced the input plink files to my own data, there comes an error that i can't figure out . I'am wondering if the input PLINK binaries files should be prepared in some special formate? I had already update the rsid match the FUSION LD reference data. my code and error are just as follow:

 /usr/bin/Rscript ${Rscript}/FeaturePred.V2.0.R \
> --PLINK_prefix_chr ${PLINK}/myinput. \
> --weights ${weights}/GTEx.Cells_EBV-transformed_lymphocytes.P01/Cells_EBV-transformed_lymphocytes.P01.pos \
> --weights_dir ${weights}/GTEx.Cells_EBV-transformed_lymphocytes.P01/  \
> --ref_ld_chr $path_to_twas/TWAS/Fusion/LDREF/1000G.EUR. \
> --plink plink \
> --ref_maf $path_to_twas/TWAS/Fusion/LDREF/1000G.EUR. \
> --pigz $path_to_twas/TWAS/Fusion/TWAS-GSEA-master/pigz-2.6/pigz \
> --chr 1 \
> --output demo2 \
> --n_cores 6 \
> --memory 50000
Error in if (n_flip > 0) { : missing value where TRUE/FALSE needed
Execution halted

Looking forward to your kindly reply! Thanks!

opain commented 3 years ago

Hello,

Thank you for your question. Apologies the error message is not more useful. Please may you post the .log file? This might highlight something.

Best wishes,

Ollie

On 18 Apr 2021, at 13:47, freshfischer @.***> wrote:

 @opain Hello, it's very kind that you make this algorithms. The Example data could run successfully. But when i replaced the input plink files to my own data, there comes an error that i can't figure out . I'am wondering if the input PLINK binaries files should be prepared in some special formate? I had already update the rsid match the FUSION LD reference data. my code and error are just as follow:

/usr/bin/Rscript ${Rscript}/FeaturePred.V2.0.R \

--PLINK_prefix_chr ${PLINK}/myinput. \ --weights ${weights}/GTEx.Cells_EBV-transformed_lymphocytes.P01/Cells_EBV-transformed_lymphocytes.P01.pos \ --weights_dir ${weights}/GTEx.Cells_EBV-transformed_lymphocytes.P01/ \ --ref_ld_chr /data/lidh/NPC/TWAS/Fusion/LDREF/1000G.EUR. \ --plink plink \ --ref_maf /data/lidh/NPC/TWAS/Fusion/LDREF/1000G.EUR. \ --pigz /data/lidh/NPC/TWAS/Fusion/TWAS-GSEA-master/pigz-2.6/pigz \ --chr 1 \ --output demo2 \ --n_cores 6 \ --memory 50000 Error in if (n_flip > 0) { : missing value where TRUE/FALSE needed Execution halted Looking forward to your kindly reply! Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

opain commented 3 years ago

Thinking about this more, I suspect your data contains variants with allele codes other than A,T,C,G (i.e. INDELs). Are there INDELs present in your data? I should update the script to remove these variants, rather than crash.

LDHHAHA commented 3 years ago

@opain Hello,I met the same error~,So I run the script below,and i found the problem is the n_flip is NA,but i counld not solve it. When the ref and the target merged,the INDELs were skippet,so i do not think remove these variants would work.

table(Ref_Target$IUPAC.x)

K     M     R     Y 

4811 5346 23517 23811

table(Ref_Target$IUPAC.y)

K     M     R     Y 

4811 5346 23517 23810

table(Ref_Target$IUPAC.x,Ref_Target$IUPAC.y)

    K     M     R     Y

K 4811 0 0 0 M 0 5346 0 0 R 0 0 23517 0 Y 0 0 0 23810

n_flip<-sum(Ref_Target$IUPAC.x == 'R' & Ref_Target$IUPAC.y == 'Y' |

  • Ref_Target$IUPAC.x == 'Y' & Ref_Target$IUPAC.y == 'R' |
  • Ref_Target$IUPAC.x == 'K' & Ref_Target$IUPAC.y == 'M' |
  • Ref_Target$IUPAC.x == 'M' & Ref_Target$IUPAC.y == 'K' ) n_flip [1] NA

the log files like this:

FeaturePred V2.0

V1.0 20/02/2019

#################################################################

Options are: $PLINK_prefix_chr [1] "${PLINK}/plink.file."

$weights [1] "${weights}/Cells_EBV-transformed_lymphocytes.P01.pos"

$weights_dir [1] "${weights}/GTEx.Cells_EBV-transformed_lymphocytes.P01/"

$ref_ld_chr [1] "./LDREF/1000G.EUR."

$n_cores [1] 6

$score_files [1] NA

$ref_expr [1] NA

$memory [1] 50000

$plink [1] "plink"

$save_score [1] TRUE

$save_ref_expr [1] TRUE

$output [1] "demo2"

$pigz [1] "pigz"

$targ_pred [1] TRUE

$ref_maf [1] "./LDREF/1000G.EUR."

$chr [1] 1

$help [1] FALSE

Analysis started at 2021-04-20 07:29:54 Harmonsising reference and target data...

LDHHAHA commented 3 years ago

haha~ I added the "Ref_Target <-na.omit(Ref_Target)" to remove the NA ,and it worked. I wonder this is the right action to solve the error~ Ref_Target<-merge(Ref, Target, by='V2') Ref_Target <-na.omit(Ref_Target) ##### added

n_flip<-sum(Ref_Target$IUPAC.x == 'R' & Ref_Target$IUPAC.y == 'Y' | 
                        Ref_Target$IUPAC.x == 'Y' & Ref_Target$IUPAC.y == 'R' | 
                        Ref_Target$IUPAC.x == 'K' & Ref_Target$IUPAC.y == 'M' |
                        Ref_Target$IUPAC.x == 'M' & Ref_Target$IUPAC.y == 'K' )
opain commented 3 years ago

Thank you LDHHAHA for your input. This error must occur due to the presence some variants with RSIDs that match the reference, but are not SNPs. I have just made an update that removes variants that are not SNPs from either the reference or target, writes these removed SNPs to a file called 'Ref_non_SNPs.txt' or 'Targ_non_SNPs.txt'. This should resolve the error, and provide insight into which variants were not SNPs. Please let me know if this works for you.

LDHHAHA commented 3 years ago

Thank you LDHHAHA for your input. This error must occur due to the presence some variants with RSIDs that match the reference, but are not SNPs. I have just made an update that removes variants that are not SNPs from either the reference or target, writes these removed SNPs to a file called 'Ref_non_SNPs.txt' or 'Targ_non_SNPs.txt'. This should resolve the error, and provide insight into which variants were not SNPs. Please let me know if this works for you.

Amazing~ Yes, it works. I tested my data used your new script and it succeeded. Thank you a lot~

opain commented 3 years ago

Thank you for confirming @LDHHAHA.

@freshfischer, feel free to reopen the issue if your error persists.