How do you post on this forum?
1
0
Entering edit mode
yousavdj • 0
@9611120f
Last seen 10 months ago
United States

I have been trying for over an hour to get a question through on this forum and whatever filter you're using absolutely will not let me do it. I have read through your posting guide. I have looked at the tutorial post. Are there a step-by-step instruction on how to formulate a post on your forum that will get past your inscrutable filters? I'm not an expert R user, and it feels like you expect somebody to be one in order to use your forum. I have a question about pcaMethods, it is giving me an error that it is not available for my version of R, but I have the latest version so I don't understand why it won't load. I've tried to post this question with my code and output included but I cannot get it to post with the code attached.

pcaMethods • 1.1k views
ADD COMMENT
1
Entering edit mode

How about relaxing and show what error you encounter? Bioconductor and especially this forum here is driven on a volunteer basis, so please dampen your tone a bit, would you? I understand errors can be frustrating, but please lets not blame that on the people here.

ADD REPLY
0
Entering edit mode

Yes apologies, I'm not trying to blame people here for errors. I could not get my question to post however, I assume for syntax reasons but I'm really not sure and there's no indication or guidance to point to what exactly is not passing through the forum's filter. I do not have these problems on, for instance, SAS forums.

Below is the question. I could not get the associated code and output to pass through the filters.

I am trying to run a PCA on a deep-sea chemistry dataset with non-random missing data. Because of the nature of the data, there are virtually no lines where every variable is available. I have been using chatGPT to help me find a version of PCA that could handle this type of dataset and it recommended using the pcaMethods package from Bioconducter but I am having a really hard time trying to install and run it.

I keep getting an error that "package 'pcaMethods' is not available for this version of R." but I have the most current version (4.3.2 , Rstudio 2023.12.1 Build 402). Below is my code and output, any help would be much appreciated!

ADD REPLY
1
Entering edit mode

It's not clear what filters you are talking about. When you start to post a new question, it literally says 'Type your question here' and 'copy/paste your code here'. In your last comment you say you post code, but do not. Here is some code

> library(BiocManager)
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.1 (2023-06-16 ucrt)
> install("pcaMethods")
'getOption("repos")' replaces Bioconductor standard repositories, see 'help("repositories", package =
"BiocManager")' for details.
Replacement repositories:
    CRAN: https://cran.rstudio.org
Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.1 (2023-06-16 ucrt)
Installing package(s) 'pcaMethods'
trying URL 'https://bioconductor.org/packages/3.18/bioc/bin/windows/contrib/4.3/pcaMethods_1.94.0.zip'
Content type 'application/zip' length 1415341 bytes (1.3 MB)
downloaded 1.3 MB

package 'pcaMethods' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\jmacdon\AppData\Local\Temp\Rtmpc5OtRW\downloaded_packages
Installation paths not writeable, unable to update packages
  path: C:/Program Files/R/R-4.3.1/library
  packages:
    cluster, foreign, KernSmooth, lattice, MASS, Matrix, mgcv, nlme, rpart, spatial, survival
Old packages: 'BSgenome', 'GenomeInfoDb', 'GenomicFeatures', 'ggnewscale', 'IDPmisc'
Update all/some/none? [a/s/n]: n
> library(pcaMethods)
Loading required package: Biobase
Loading required package: BiocGenerics

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call,
    duplicated, eval, evalq, Filter, Find, get, grep, grepl, intersect, is.unsorted, lapply, Map,
    mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank, rbind, Reduce,
    rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min

Welcome to Bioconductor

    Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.


Attaching package: 'pcaMethods'

The following object is masked from 'package:stats':

    loadings
ADD REPLY
0
Entering edit mode

Oh, and

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] pcaMethods_1.94.0   Biobase_2.62.0      BiocGenerics_0.48.1 BiocManager_1.30.22

loaded via a namespace (and not attached):
[1] compiler_4.3.1 tools_4.3.1    Rcpp_1.0.12
ADD REPLY
0
Entering edit mode

Thank you for your help. I was able to use the code provided above to troubleshoot my issue and got the pcaMethods package to work on my computer. I was also able to produce a PCA, but I am now having trouble visualizing the eigenvalues to determine how successful the PCA was. I am using code to produce a "screeplot" that I got from chatGPT, but it doesn't seem to work with this package. Please see the code below. Any suggestions on how to produce a screeplot or a different way to visualize the eigenvalues?

Thank you.

> screeplot(pca_result, type = "line", main = "Scree Plot") Error in x$sdev : $ operator not defined for this S4 class

'> sessionInfo() R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/Los_Angeles tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] BiocManager_1.30.22 pcaMethods_1.94.0 Biobase_2.62.0 BiocGenerics_0.48.1

loaded via a namespace (and not attached): [1] compiler_4.3.2 cli_3.6.2 tools_4.3.2 Rcpp_1.0.12 cellranger_1.1.0 readxl_1.4.3'

ADD REPLY
0
Entering edit mode
@james-w-macdonald-5106
Last seen 14 hours ago
United States

You should probably stop using chatGPT because it is just telling you random stuff. If all you want to do is a principal components plot, then pcaMethods is not the tool for the job. That package is mostly for data with missingness and imputation thereof. The canonical method to use for a basic PCA is princomp, but these days it's been mostly superceded by prcomp. Both of which have help pages you can consult.

If your question is off-topic for this site (which is meant specifically for questions pertaining to Bioconductor packages), you might try at biostars.org (general bioinformatics/statistics) or stackoverflow.com (more programming, but some statistics as well) or R-help (r-help@r-project.org).

ADD COMMENT
0
Entering edit mode

Yes chatGPT seems to have its limitations, it doesn't really seem to know much about the Bioconductor packages which led me to this forum.

I chose the pcaMethods package specifically because my dataset has non-random missing data that I need to impute. So I do think the ppca option in pcaMethods is appropriate for my analysis.

I am, however, having trouble reconciling the advice for PCA in general with what's available in the pcaMethods package. A lot of the code I find from other resources (e.g., chatGPT, stackoverflow) doesn't work with the pcaMethods package. For instance, I replaced the score data labels with dots instead of the row numbers:

biplot(pca_result, choices = c(1, 2), main = "Biplot of PC1 and PC2", xlabs=rep(".", nrow(scaled_data)), cex = 1.5)

But now I'm having difficulty increasing the size of the dots. ChatGPT suggests the following:

text(pca_result$ind$coord[, 1:2], labels = rownames(pca_result$ind$coord), cex = 1.8)

But I receive the following error message:

Error in pca_result$ind : $ operator not defined for this S4 class

This seems to be a re-occurring problem between code I'm finding from other sources, and what will work with this package. I've also tried using options listed in the bioconductor.org documentation (changing scex and lcex independently) but that also doesn't seem to work:

There were 50 or more warnings (use warnings() to see the first 50)
warnings()
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
  "scex" is not a graphical parameter

Is there a way to change my score labels to dots, and increase their size? Thanks,

ADD REPLY

Login before adding your answer.

Traffic: 824 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6