methrix icon indicating copy to clipboard operation
methrix copied to clipboard

PCA plotting error

Open questcof opened this issue 10 months ago • 4 comments

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!

questcof avatar Apr 08 '24 16:04 questcof

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.

PoisonAlien avatar Apr 09 '24 07:04 PoisonAlien

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!

questcof avatar Apr 09 '24 10:04 questcof

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?

PoisonAlien avatar Apr 09 '24 10:04 PoisonAlien

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

tkik avatar Apr 10 '24 21:04 tkik

Closing due to inactivity.

tkik avatar Oct 09 '24 08:10 tkik