CompEpigen / methrix

An R :package: for fast and flexible DNA methylation analysis
https://www.bioconductor.org/packages/release/bioc/html/methrix.html
Other
28 stars 11 forks source link

PCA plotting error #31

Open questcof opened 5 months ago

questcof commented 5 months ago

Hello,

I am following the wonderfully detailed methrix tutorial, currently on section 2 (see https://compepigen.github.io/methrix_docs/articles/03-QC_reports.html), and I am trying to plot a PCA.

The example command is: methrix::plot_pca(mpca, m=meth, col_anno = "Day", shape_anno = "Replicate")

and I have changed it to reflect my own data: methrix::plot_pca(mpca, m=meth_ext$snp_filtered, col_anno = "Risk", shape_anno = "New.risk.group")

I have been able to follow the tutorial up to this point with no issues but I get the following error:

Error in geom_point(): ! Problem while computing aesthetics. ℹ Error occurred in the 1st layer. Caused by error in FUN(): ! data must be uniquely named but has duplicate columns

I have checked the colnames of my meth_ext object and the sample_anno but I cannot see any duplicated columns. Any idea what is going on, what am I missing?

I also noticed that in the tutorial there is no need to specify meth_ext$snp_filtered but if I do not I get this error:

A valid methrix object needs to be supplied.

Is that to be expected?

Thank you in advance!

PoisonAlien commented 5 months ago

Hi,

Thanks for the issue. It appears that your colData has duplicated column names. You will have to either rename one of them or remove it so that ggplot knows which column to use.

# Check if there are any duplicated columns
colData(meth) |> colnames() |> duplicated() |> any()

I hope this helps.

questcof commented 5 months ago

Hello,

Thank you for that suggestion.

I tried: colData(meth) |> colnames() |> duplicated() |> any()

and it threw an error:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'duplicated': error in evaluating the argument 'x' in selecting a method for function 'colnames': unable to find an inherited method for function ‘colData’ for signature ‘"list"’

So I modified it to call the filtered data: colData(meth$snp_filtered) |> colnames() |> duplicated() |> any()

Which returns

[1] FALSE

If no column names are duplicated, do you have any other ideas for what is causing this error?

Thank you again in advance!

PoisonAlien commented 5 months ago

Hi,

You will have to check if any column names in the colData slot are duplicated. colData() takes methrix object as input. From the error, it appears meth is a list. Could you please try it again with your methrix object?

tkik commented 5 months ago

Hi, It seems your meth object is a list, because you did a snp filtering before plotting. This gives back a list, with your snp filtered methrix object being meth$snp_filtered. To make it easier, you can do meth_filt <- meth$snp_filtered