YuanTian1991 / ChAMP

21 stars 23 forks source link

champ.Block, arguments must have same length, but they do #19

Open bhanratt opened 3 years ago

bhanratt commented 3 years ago

Hi, I am getting this error with the champ.Block function complaining that the arguments are different lengths. But they are the same length. See below:

> myBlock <- champ.Block(beta=Beta,pheno=pheno,arraytype="EPIC")
[===========================]
[<<<< ChAMP.Block START >>>>]
-----------------------------
<< Load Annotation Successfully >>
<< Get Clusters by cgi-info Successfully >>
<< Calculate Average Beta Value Successfully >>
<< Generate Block Position Successfully >>
<< New Clusters are generated for blocks >>
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  arguments must have same length
> length(colnames(Beta))
[1] 56
> length(pheno)
[1] 56
> 
YuanTian1991 commented 3 years ago

Hi, the error appears in the aggregate function. It indicates I think internal mismatch, not your beta/pheno. One possibility is you have NC value in your beta, could you check that.

And sorry I previously only answer question champ450K@gmail.com, did not notice github issues.

thscandolara commented 1 year ago

Hi Yuan. I'm getting the same error...

myBlock <- champ.Block(beta = myCombat,
                       pheno = myLoad$pd$Sample_type,
                       arraytype = "EPIC",
                       cores = 3)

===========================]
[<<<< ChAMP.Block START >>>>]
-----------------------------
<< Load Annotation Successfully >>
<< Get Clusters by cgi-info Successfully >>
<< Calculate Average Beta Value Successfully >>
<< Generate Block Position Successfully >>
<< New Clusters are generated for blocks >>
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  arguments must have same length

I had a similar problem before with the champ.SVD command, and thus I checked the class of myCombat:

> class(myCombat)
[1] "matrix" "array"

> length(myLoad$pd$Sample_type)
[1] 96
> length(colnames(myCombat))
[1] 0

Before, the solution was to use %>% as.data.frame(). I tried it here as well, but faced the same error:

myBlock <- champ.Block(beta = myCombat %>% as.data.frame(),
                       pheno = myLoad$pd$Sample_type,
                       arraytype = "EPIC",
                       cores = 3)

===========================]
[<<<< ChAMP.Block START >>>>]
-----------------------------
<< Load Annotation Successfully >>
<< Get Clusters by cgi-info Successfully >>
<< Calculate Average Beta Value Successfully >>
<< Generate Block Position Successfully >>
<< New Clusters are generated for blocks >>
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  arguments must have same length

Any solution?

Thanks!!

YuanTian1991 commented 1 year ago

Seems something is wrong with your myCombat object which is empty…

Can I see your code how you generated myCombat?

Best Tian

On 29 Mar 2023, at 17:23, thscandolara @.***> wrote:

Hi Yuan. I'm getting the same error...

myBlock <- champ.Block(beta = myCombat, pheno = myLoad$pd$Sample_type, arraytype = "EPIC", cores = 3)

===========================] [<<<< ChAMP.Block START >>>>]

<< Load Annotation Successfully >> << Get Clusters by cgi-info Successfully >> << Calculate Average Beta Value Successfully >> << Generate Block Position Successfully >> << New Clusters are generated for blocks >> Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length I had a similar problem before with the champ.SVD command, and thus I checked the class of myCombat:

class(myCombat) [1] "matrix" "array"

length(myLoad$pd$Sample_type) [1] 96 length(colnames(myCombat)) [1] 0 Before, the solution was to use %>% as.data.frame(). I tried it here as well, but faced the same error:

myBlock <- champ.Block(beta = myCombat %>% as.data.frame(), pheno = myLoad$pd$Sample_type, arraytype = "EPIC", cores = 3)

===========================] [<<<< ChAMP.Block START >>>>]

<< Load Annotation Successfully >> << Get Clusters by cgi-info Successfully >> << Calculate Average Beta Value Successfully >> << Generate Block Position Successfully >> << New Clusters are generated for blocks >> Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length

Any solution?

Thanks!!

— Reply to this email directly, view it on GitHub https://github.com/YuanTian1991/ChAMP/issues/19#issuecomment-1488918619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQTO4ZVKUGSUVZNTDAWHE3W6ROWTANCNFSM4Z6MQJUQ. You are receiving this because you commented.

thscandolara commented 1 year ago

Sure!

> myCombat <-  champ.runCombat(beta = myNorm,
                                                           pd = myLoad$pd,
                                                           variablename = "Sample_type",
                                                           batchname = c("Slide"),
                                                           logitTrans = T)
[===========================]
[<< CHAMP.RUNCOMBAT START >>]
-----------------------------
<< Preparing files for ComBat >>
[Combat correction will be proceed with 739883 probes and 96 samples.]

<< Following Factors in your pd(sample_sheet.csv) could be applied to Combat: >>
<X>(character)
<Sample_number>(character)
<BNT_number>(character)
<Slide>(character)
<Array>(character)
<barcodes>(character)
[champ.runCombat have automatically select ALL factors contain at least two different values from your pd(sample_sheet.csv).]

<< Following Factors in your pd(sample_sheet.csv) can not be corrected: >>
<Sample_type>
[Factors are ignored because they are conflict with variablename, or they contain ONLY ONE value across all Samples, or some phenotype contains less than 2 Samples.]
As your assigned in batchname parameter: Slide will be corrected by Combat function.

<< Start Correcting Slide >>
~Sample_type
<environment: 0x5637e72e6bc0>
Generate mod success. Started to run ComBat, which is quite slow...
Found12batches
Adjusting for1covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Adjusting the Data

champ.runCombat success. Corrected dataset will be returned.
                   [,1]         [,2]         [,3]         [,4]         [,5]         [,6]         [,7]         [,8]         [,9]
cg07881041 0.9356209488 0.9370760137 0.8884847451 0.9139819234 0.7711819224 9.190186e-01 0.9300341920 0.9341799629 9.115546e-01
cg03513874 0.9253785089 0.8719637819 0.8571651479 0.9238711420 0.7026405018 9.107074e-01 0.9051577008 0.8550230517 9.325432e-0

I ran everything with myCombat:

champ.SVD(beta=myCombat %>% as.data.frame())

myDMP <- champ.DMP(beta = myCombat,
                   pheno=myLoad$pd$Sample_type,
                   arraytype = "EPIC")

And etc. Everything was running smoothly, except for QC.GUI (in which I got the error below) and champ.Block:

QC.GUI(beta = myCombat,
       pheno = myLoad$pd$Sample_type,
       arraytype = "EPIC")

#Warning: Error in data.frame: arguments imply differing number of rows: 96, 0
RosycloudsRan commented 1 year ago

[===========================] [<<<< ChAMP.Block START >>>>]

Loading required package: IlluminaHumanMethylation450kanno.ilmn12.hg19 << Load Annotation Successfully >> << Get Clusters by cgi-info Successfully >> << Calculate Average Beta Value Successfully >> << Generate Block Position Successfully >> << New Clusters are generated for blocks >> Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length Calls: champ.Block ... aggregate -> aggregate.default -> aggregate.data.frame Execution halted

RosycloudsRan commented 1 year ago

Hi, Yuan.

Could you please tell me how to deal with this

RosycloudsRan commented 1 year ago

what is NC value???