object 'ReorderModel' not found

1,027 views
Skip to first unread message

frw...@gmail.com

unread,
Jul 8, 2019, 10:32:54 AM7/8/19
to Genomic SEM Users
I am running the following script to familiarize myself with GenomicSEM. I am unable to execute the commonfactor command and receive the error that the ReorderModel object cannot be found. I appreciate any suggestions to get around this. Thank you!


ldsc_out <- ldsc(traits =c("ADHD.sumstats.gz","AlcDep.sumstats.gz","Anorexia.sumstats.gz",
                            "Anxiety.sumstats.gz","Autism.sumstats.gz"),
                  trait.names= c("adhd","alcdep","anorexia","anxiety","autism"),
                  ld = "eur_w_ld_chr/", wld="eur_w_ld_chr/",
                  sample.prev = NA,
                  population.prev = NA)

k<-nrow(ldsc_out$S)
SE<-matrix(0, k, k)
SE[lower.tri(SE,diag=TRUE)] <-sqrt(diag(ldsc_out$V))

DWLS<- commonfactor(ldsc_out,estimation="DWLS")
ML<- commonfactor(ldsc_out,estimation="ML")

Andrew Grotzinger

unread,
Jul 8, 2019, 11:04:21 AM7/8/19
to Genomic SEM Users
Can you post the output of ldsc_out$S to the screen? Normally that error pops up if there are missing values in the genetic covariance matrix. If that's the case I can help you figure out why that's occurring, but want to see first if that's the root cause. 

frw...@gmail.com

unread,
Jul 8, 2019, 11:07:43 AM7/8/19
to Genomic SEM Users

Hey Andrew, here is the output from ldsc_out$S.


Andrew Grotzinger

unread,
Jul 12, 2019, 11:51:14 AM7/12/19
to Genomic SEM Users
Just an update for the general group; the issue was that lavaan package, which Genomic SEM uses to estimate models, posted a package update on July 3rd, 2019 that was causing some mild incompatibility issues. Genomic SEM was appropriately updated and this model is now running. Thanks again Frank for brining this to our attention! 

tristude...@gmail.com

unread,
Mar 19, 2020, 9:20:01 PM3/19/20
to Genomic SEM Users
Hi Andrew!
I think I'm having some of the same issues as described here.

When running the script (last bits pasted here):
covstruc<-BW
SNPs<-p_sumstats
estimation<-"DWLS"
parallel<-FALSE
SNPSE<-.005

pfactor_GWAS<-commonfactorGWAS(covstruc=covstruc, SNPs=SNPs, estimation = estimation,parallel=parallel,SNPSE=SNPSE)

I get the following output:

[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

This is the output from my ldsc:
BW$S
          OwnBW Maternal-1offBW Paternal-1offBW
[1,] 0.14504120      0.09228280      0.05636062
[2,] 0.09228280      0.12408131      0.02114014
[3,] 0.05636062      0.02114014      0.04426345

Except for chancing phenotype I've basically kept the script the same as we got from you in Boulder a couple of weeks ago. Any suggestions on what the error might me?
Thanks, Helen

Andrew Grotzinger

unread,
Mar 19, 2020, 10:27:30 PM3/19/20
to Genomic SEM Users
Hi Helen, 

If you run the commonfactor function on the LDSC object alone what does the output look like? Just to confirm, your p_sumstats object is a new one you created for these three phenotypes, correct (and not the summary stats file provided from the workshop)? Others were getting this error before because a "fake" model of sorts used to obtain the reordering of the sampling covariance matrix was failing out, but I put in lots of relaxed convergence criteria for this one model so I'm just throwing out some ideas (baseline common factor model without individual SNPs fits poorly, incorrect sumstats object) of why this might be happening. Of course, it could be that the code is just getting stuck at this point, and to check this i'd ask that you also send the LDSC object and sumstats output to my e-mail at agro...@utexas.edu so I can take a look. 

Thanks!
 -Andrew

Andrew Grotzinger

unread,
Mar 24, 2020, 5:47:19 PM3/24/20
to Genomic SEM Users

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")

eva van walree

unread,
Apr 15, 2021, 10:59:51 AM4/15/21
to Genomic SEM Users
Hi Andrew.

I'm having the same issue as the one described here.
I'm trying to run a common factor GWAS:

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

Do you have any suggestions of how to tackle this?

Thanks in advance for your help (and for building the tool!),

Best wishes,

Eva
Op dinsdag 24 maart 2020 om 22:47:19 UTC+1 schreef agro...@gmail.com:

agro...@gmail.com

unread,
Apr 15, 2021, 11:17:46 AM4/15/21
to Genomic SEM Users
Hi Eva, 

The one other time I've seen this come up is when the sumstats function was accidentally fed less (or more) traits than are present in the LDSCoutput. If that's not the case could you send me (agro...@utexas.edu) the LDSCoutput and first 100 rows of the sumstats output so I can take a look? 

Best, 
  Andrew

eva van walree

unread,
Apr 16, 2021, 3:32:08 AM4/16/21
to Genomic SEM Users
Hi Andrew,

I indeed made a typo at some point which caused an un-similar number of traits being fed into the sumstats vs the LDSCoutput. My bad!

Best,
Eva

Op donderdag 15 april 2021 om 17:17:46 UTC+2 schreef agro...@gmail.com:

agro...@gmail.com

unread,
Apr 16, 2021, 8:38:56 AM4/16/21
to Genomic SEM Users
Hi Eva, 

Happens all the time! In fact, I'm glad you raised this issue; the error message you received is uninformative as to the actual issue so I updated the commonfactorGWAS function this morning to print an error about their being unequal numbers of traits across the sumstats and ldsc output should anyone run into the same issue in the future. 

Best, 
 Andrew

Mehreen Soomro

unread,
Nov 22, 2022, 11:08:49 AM11/22/22
to Genomic SEM Users
Hi Andrew,

I am trying to run HDl and LDSC for two traits from GWAS summary statistics. I am able to run all the steps without any problem until I try to run usermodel or commonfactor model with the following error.

hdl.cors <-  usermodel(covstruc = hdl.covstruct ,estimation = "DWLS", model = model )
Error in solve.default(V_LD) :
  system is computationally singular: reciprocal condition number = 4.24507e-35

output from hdl looks like:
$V
              [,1]          [,2]          [,3]
[1,]  5.820539e-04 -1.694185e-08 -9.654111e-23
[2,] -1.694185e-08  2.318589e-11 -3.328948e-26
[3,] -9.654111e-23 -3.328948e-26  2.478273e-38

$S
                RA           CVD

[1,]  1.552573e-01 -7.486012e-06
[2,] -7.486012e-06  3.853758e-08

$I
           [,1]       [,2]
[1,]  1.1376541 -0.0163208
[2,] -0.0163208  1.0000000

$complete
     [,1]       [,2]      
[1,] "(99.03%)" "(99.93%)"

agro...@gmail.com

unread,
Nov 22, 2022, 12:41:25 PM11/22/22
to Genomic SEM Users

Try running: 
hdl.cors <-  usermodel(covstruc = hdl.covstruct ,estimation = "DWLS", model = model ,toler=1e-36)

You are seeing that error because it is having trouble inverting the sampling covariance (V) matrix. This is typically safe to ignore, but requires manually setting the tolerance to a lower value to encourage checking over the model output to confirm everything looks appropriate (e.g., no negative residual variances, no factor correlations > 1). 

jennifer harris

unread,
Jun 29, 2023, 12:32:57 PM6/29/23
to Genomic SEM Users
Howdy Andrew,

I'm also getting this error:

> 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.


agro...@gmail.com

unread,
Jun 29, 2023, 1:26:40 PM6/29/23
to Genomic SEM Users
Hi Jennifer, 

I just tried rerunning the code with another dataset and can't reproduce the error (but would point out that you have Output listed as an argument which I had to remove as this is not an argument for that function). I'm pretty sure this was fixed in a recent code update if you could try re-installing the package, restarting R, and rerunning. If you are still getting the error if you could post the first five rows of your sumstats that would be helpful. 

Best, 
  Andrew

jennifer harris

unread,
Jun 29, 2023, 4:29:38 PM6/29/23
to Genomic SEM Users
Reloading Lavaan worked.  I have another error now but it's about the difference between replacement and data numbers.  Thanks for the help.

roya karimi

unread,
Oct 10, 2023, 7:04:56 AM10/10/23
to Genomic SEM Users
Hello everyone,

I am receiving this error after running the commonfactorGWAS() code:  Error in unserialize(socklist[[n]]) : error reading from connection

Could you please help me with finding its source?


Best,
Roya

agro...@gmail.com

unread,
Oct 20, 2023, 5:09:35 PM10/20/23
to Genomic SEM Users
Hi Roya, 

This looks like something about how running in parallel is interfacing with your computing cluster. To be honest that kind of error is hard for us to troubleshoot because it can often be cluster specific in terms of the source of the error. I would recommend trying to run a small batch of 100 SNPs not in parallel on the cluster to confirm that running in parallel is the issue. 

Best, 
  Andrew
Reply all
Reply to author
Forward
0 new messages