xinhe-lab / ctwas

package for the causal TWAS project
https://xinhe-lab.github.io/ctwas/
MIT License
34 stars 12 forks source link

'subscript out of bounds' error when running process_weights() #56

Open Chris-Wills opened 15 hours ago

Chris-Wills commented 15 hours ago

Hi, im receiving this error when following the new cTWAS version tutorials and i'm not sure where to begin solving it:

> tissue_weights <- preprocess_weights(weight,
                                      region_info,
                                      gwas_snp_ids = z_snp$id,
                                      snp_map = snp_map,
                                      type = "expression",
                                      context = TISSUE,
                                      weight_format = "PredictDB", 
                                      drop_strand_ambig = TRUE,
                                      scale_predictdb_weights = TRUE,
                                      load_predictdb_LD = TRUE,
                                      ncore = 8)
2024-10-11 12:28:57.952098 INFO::Load weight: /scratch/c.c1214964/cell_specific_TWAS/data/DB_files/Astrocytes.weights_main.db
2024-10-11 12:28:57.955291 INFO::weight_name: Astrocytes_expression
2024-10-11 12:28:57.957155 INFO::type: expression
2024-10-11 12:28:57.958958 INFO::context: Astrocytes
2024-10-11 12:28:57.962862 INFO::Load PredictDB weights
2024-10-11 12:29:05.125009 INFO::Number of molecular traits in weights: 11041
2024-10-11 12:29:05.126549 INFO::No 'protein_coding' in 'extra_table$gene_type'. Skipped filtering protein coding genes.
2024-10-11 12:29:05.127658 INFO::Load PredictDB LD
2024-10-11 13:02:10.574406 INFO::Remove 7 molecular traits without predictdb LD
2024-10-11 13:02:11.047144 INFO::Number of molecular traits in weights: 11034
2024-10-11 13:02:11.331974 INFO::Number of variants in weights: 1949168
2024-10-11 13:02:14.257097 INFO::10986 molecular traits and 1585419 variants left after filtering by GWAS and the reference.
2024-10-11 13:02:15.438338 INFO::Harmonizing and processing weights ...
Error in FUN(X[[i]], ...) : subscript out of bounds
In addition: Warning message:
In mclapply(X, FUN, mc.cores = mc.cores) :
  all scheduled cores encountered errors in user code

Thanks

kevinlkx commented 13 hours ago

There may be some issue with the weights. Can you try with ncore = 1, and send us the error messages?

Chris-Wills commented 12 hours ago

output on 1 core:


2024-10-11 15:10:41.534125 INFO::Load weight: /scratch/c.c1214964/cell_specific_TWAS/data/DB_files/Astrocytes.weights_main.db
2024-10-11 15:10:41.535846 INFO::weight_name: Astrocytes_expression
2024-10-11 15:10:41.536955 INFO::type: expression
2024-10-11 15:10:41.537959 INFO::context: Astrocytes
2024-10-11 15:10:41.53914 INFO::Load PredictDB weights
2024-10-11 15:10:46.857979 INFO::Number of molecular traits in weights: 11041
2024-10-11 15:10:46.859248 INFO::No 'protein_coding' in 'extra_table$gene_type'. Skipped filtering protein coding genes.
2024-10-11 15:10:46.860123 INFO::Load PredictDB LD
2024-10-11 15:41:30.813686 INFO::Remove 7 molecular traits without predictdb LD
2024-10-11 15:41:31.265229 INFO::Number of molecular traits in weights: 11034
2024-10-11 15:41:31.556502 INFO::Number of variants in weights: 1949168
2024-10-11 15:41:34.617714 INFO::10986 molecular traits and 1585419 variants left after filtering by GWAS and the reference.
2024-10-11 15:41:35.861548 INFO::Harmonizing and processing weights ...
Error in `[<-`(`*tmp*`, i, j, value = 1) : subscript out of bounds
kevinlkx commented 12 hours ago

Thanks! Sorry, the message is not very informative. If convenient, would you mind sharing your input to this function? You can put the weight file, region_info, z_snp$id, and snp_map in a zip file on Dropbox, Google Drive, etc. and share the link. (you can skip the snp_map if you use the snp_map we provided). I could help check it.