Hi Helen,
It turns out the issue was that your trait names included mathematical arguments in the names (e.g., + or -) that was being misread by lavaan. I’ve updated the GWAS functions and ldsc function to print a warning that reads:
“Your trait names specified when running the ldsc function include mathematical arguments (e.g., + or -) that will be misread by lavaan. Please rename the traits."
I appreciate you bringing this to my attention because the ReorderModel warning you were getting is obviously very uninformative. You can either re-run ldsc with the trait names changed, or change the column names of the ldsc output using the first piece of the code below. I would note that one of your variables OwnBW variable produces a negative residual variance that the GWAS function will print a warning about. I determined this after I saw the warning from the GWAS function, and then ran the commonfactor function to see which variable was producing the negative residual. I then specified a usermodel with a constraint on that particular residual, which seems to produce sensible output. Finally, I ran userGWAS on a subset of SNPs just to see if that output also seemed sensible, and it seems to be running without any errors or warning at least for the handful I ran through. Hope this helps and let me know if you end up having any more issues or questions!
Best,
Andrew
#rename columns of ldsc output
colnames(BW$S)<-c("OwnBW","Maternal1offBW","Paternal1offBW")
#run commonfactor model: produces negative residual for OwnBW
commonfactor(covstruc)
#run usermodel with constraint on OwnBW residual
base_model<-"F1=~OwnBW+Maternal1offBW+Paternal1offBW
OwnBW~~a*OwnBW
a > .001"
usermodel(covstruc,model=base_model)
#run userGWAS with same constraint
GWAS_model<-"F1=~OwnBW+Maternal1offBW+Paternal1offBW
F1~SNP
OwnBW~~a*OwnBW
a > .001"
#output looks good on a subset of 50 SNPs that I ran
userGWAS(covstruc=covstruc, SNPs=SNPs, model=GWAS_model,estimation = estimation,parallel=parallel,SNPSE=SNPSE,sub="F1~SNP")
MetS <- commonfactorGWAS(covstruc = LDSCoutput, SNPs = mets_sumstats, estimation = "DWLS", cores = NULL, toler = FALSE, SNPSE = FALSE, parallel = TRUE, GC="standard",MPI=FALSE)
After having done LDSC and preparing the sumstats for GWAS, both of which seem to go OK.
The error I'm getting is:
[1] "Please check the log files to ensure that all columns were interpreted correctly and no warnings were issued for any of the summary statistics files."
Error in rearrange(k = k + 1, fit = ReorderModel, names = rownames(S_Fullrun)) :
object 'ReorderModel' not found
Calls: commonfactorGWAS -> rearrange -> rownames -> inspect
> LDSCoutput$S
FG_wo_UKB SBP_UKB WC_w_UKB TG_wo_UKB SBP_UKB
[1,] 0.05829756 -0.04379578 0.07100647 0.04471677 0.01852283
[2,] -0.04379578 0.11190290 -0.06055071 -0.05811127 -0.01416700
[3,] 0.07100647 -0.06055071 0.19563437 0.04834867 0.02209590
[4,] 0.04471677 -0.05811127 0.04834867 0.10734642 0.01665025
[5,] 0.01852283 -0.01416700 0.02209590 0.01665025 0.13340983
> pfactor <- commonfactorGWAS(covstruc = LDSCoutput, SNPs = p_sumstats,
+ estimation = "DWLS", cores = NULL, toler = FALSE, SNPSE = FALSE,
+ parallel = FALSE, Output = NULL, GC="standard", MPI=FALSE)
[1] "Please note that an update was made to commonfactorGWAS on 11/21/19 so that it combines addSNPs and commonfactorGWAS."
Error in rearrange(k = k + 1, fit = ReorderModel, names = rownames(S_Fullrun)) :
object 'ReorderModel' not found
The LDSCouput$S looks like this:
> LDSCoutput$S
mood mise irri hurt fdup nerv anxi
[1,] 0.5976227 0.3637052 0.1382512 0.4463654 0.4001910 0.3661837 0.3004722
[2,] 0.3637052 0.5107654 0.1841875 0.2682851 0.4139446 0.3226187 0.3300544
[3,] 0.1382512 0.1841875 0.1876588 0.1107486 0.1230459 0.1584813 0.2284017
[4,] 0.4463654 0.2682851 0.1107486 0.4363321 0.3431585 0.2905836 0.2199402
[5,] 0.4001910 0.4139446 0.1230459 0.3431585 0.5580058 0.3472963 0.2748710
[6,] 0.3661837 0.3226187 0.1584813 0.2905836 0.3472963 0.4434810 0.2970117
[7,] 0.3004722 0.3300544 0.2284017 0.2199402 0.2748710 0.2970117 0.4549472
[8,] 0.3183817 0.2253387 0.1251515 0.3074107 0.2365158 0.2236217 0.2118528
[9,] 0.2426811 0.2725334 0.2178104 0.1873566 0.2044874 0.2509019 0.3558967
[10,] 0.2415454 0.2528371 0.1491567 0.1784612 0.2024371 0.2136218 0.2873494
[11,] 0.4232694 0.4202327 0.2951142 0.3076793 0.3070775 0.4046716 0.5239900
[12,] 0.3852344 0.2958950 0.1553911 0.3373849 0.2668155 0.2771539 0.2457026
tens emba suff lone guil
[1,] 0.3183817 0.2426811 0.2415454 0.4232694 0.3852344
[2,] 0.2253387 0.2725334 0.2528371 0.4202327 0.2958950
[3,] 0.1251515 0.2178104 0.1491567 0.2951142 0.1553911
[4,] 0.3074107 0.1873566 0.1784612 0.3076793 0.3373849
[5,] 0.2365158 0.2044874 0.2024371 0.3070775 0.2668155
[6,] 0.2236217 0.2509019 0.2136218 0.4046716 0.2771539
[7,] 0.2118528 0.3558967 0.2873494 0.5239900 0.2457026
[8,] 0.2746235 0.1835652 0.1525690 0.2919568 0.2716850
[9,] 0.1835652 0.3668367 0.2475909 0.4776579 0.2169501
[10,] 0.1525690 0.2475909 0.3707155 0.4042029 0.2764585
[11,] 0.2919568 0.4776579 0.4042029 0.7777451 0.3858659
[12,] 0.2716850 0.2169501 0.2764585 0.3858659 0.4269295
Any help would be appreciated.