This function extracts PCA loadings stored in the DimReduction slot of a geneda object and combines them with the associated metadata. It ensures that the metadata has valid rownames and aligns the PCA loadings accordingly.

ExtractPCA(object)

Arguments

object

A geneda object containing PCA results in the DimReduction slot and sample-level metadata in the metadata slot.

Value

A data.frame combining PCA loadings and sample metadata, where rows correspond to samples and columns include principal component loadings and metadata fields.

Details

The function performs several checks:

  • Ensures the input object is of class geneda.

  • Verifies that the DimReduction slot contains PCA loadings.

  • Confirms that the metadata has valid rownames.

  • Reorders the PCA loadings to match the order of metadata rows.

If metadata rownames are missing or invalid, the function throws an error.

Examples

if (FALSE) { # \dontrun{
# Example usage:
pca_results <- ExtractPCA(my_geneda_object)
head(pca_results)
} # }