From 940af1efc61004c029b45798de1f3bf0e7a82742 Mon Sep 17 00:00:00 2001 From: Mao Tian Date: Mon, 26 Aug 2024 16:51:50 -0700 Subject: [PATCH] update keras to keras3 --- DESCRIPTION | 2 +- NAMESPACE | 2 +- R/create.autoencoder.R | 2 +- R/create.autoencoder.irf.matrix.R | 4 ++-- README.md | 6 +++++- man/create.autoencoder.Rd | 6 +++--- metadata.yaml | 2 +- vignettes/iSubGenGuide.Rnw | 2 +- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4c299d1..9b3ff58 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Authors@R: c( person("Dan Knight", role = "ctb")) Description: Multi-data type subtyping, which is data type agnostic and accepts missing data. Subtyping is performed using intermediary assessments created with autoencoders and similarity calculations. Depends: R (>= 3.2.3) -Imports: ConsensusClusterPlus, cluster (>= 1.14.4), keras, tensorflow, philentropy +Imports: ConsensusClusterPlus, cluster (>= 1.14.4), keras3, tensorflow, philentropy Suggests: knitr, rmarkdown VignetteBuilder: knitr License: GPL-2 diff --git a/NAMESPACE b/NAMESPACE index 6c456b3..c8e4406 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,4 +5,4 @@ importFrom("grDevices", "colorRampPalette"); importFrom("cluster","diana"); importFrom("ConsensusClusterPlus","ConsensusClusterPlus","calcICL"); importFrom("philentropy","distance"); -import(tensorflow, keras); +import(tensorflow, keras3); diff --git a/R/create.autoencoder.R b/R/create.autoencoder.R index 92851b9..59d469c 100644 --- a/R/create.autoencoder.R +++ b/R/create.autoencoder.R @@ -60,7 +60,7 @@ create.autoencoder <- function( optimizer = 'adam' ); - ae.output.file <- paste0(sub('/$','',model.file.output.dir),'/',data.type,'_model.hdf5'); + ae.output.file <- paste0(sub('/$','',model.file.output.dir),'/',data.type,'_model.keras'); checkpoint <- callback_model_checkpoint( filepath = ae.output.file, save_best_only = TRUE, diff --git a/R/create.autoencoder.irf.matrix.R b/R/create.autoencoder.irf.matrix.R index a986708..d78b9a9 100644 --- a/R/create.autoencoder.irf.matrix.R +++ b/R/create.autoencoder.irf.matrix.R @@ -36,8 +36,8 @@ create.autoencoder.irf.matrix <- function( if (data.type %in% names(autoencoders)) { # load the neural net for the data.type model <- autoencoders[[data.type]]; - if (is.character(autoencoders[[data.type]]) && grep('hdf5$',autoencoders[[data.type]]) == 1) { - model <- load_model_hdf5( + if (is.character(autoencoders[[data.type]]) && grep('keras$',autoencoders[[data.type]]) == 1) { + model <- load_model( autoencoders[[data.type]], compile = FALSE); } diff --git a/README.md b/README.md index a738d8b..da62bcf 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,10 @@ The first step is to load the data. Here the genomic features are rows and patie ```{r load-data} # Load the library and the data included with the package library(iSubGen); +library(tensorflow); +library(keras3); +library(reticulate); + molecular.data <- list(); for(i in c('cna','methy','snv')) { molecular.data[[i]] <- load.molecular.aberration.data( @@ -231,7 +235,7 @@ IRF: Independent Reduced Features. iSubGen: integrative Subtype Generation. This tool! -Keras R package: [https://cran.r-project.org/package=keras](https://cran.r-project.org/package=keras) +keras R package: [https://cran.r-project.org/package=keras](https://cran.r-project.org/package=keras) Methylation: a DNA modification where methyl groups of are added to cytosines in DNA to help regulate DNA transcription. diff --git a/man/create.autoencoder.Rd b/man/create.autoencoder.Rd index 00759c6..9c7efec 100644 --- a/man/create.autoencoder.Rd +++ b/man/create.autoencoder.Rd @@ -4,20 +4,20 @@ \description{Create an autoencoder for dimensionality reduction using keras and tensorflow packages} \usage{ create.autoencoder(data.type, data.matrix, encoder.layers.node.nums = c(15,2), -autoencoder.activation = 'tanh', optimization.loss.function = 'mean_squared_error', +autoencoder.activation = 'tanh', optimization.loss.function = 'mean_squared_error', model.file.output.dir = '.') } \arguments{ \item{data.type}{data type ID. The ID will be used for naming the output file} \item{data.matrix}{matrix with data features as rows and patients as columns} - \item{encoder.layers.node.nums}{vector with the number of nodes for each layer when the reducing the feature dimensions within the autoencoder. The autoencoder will be made symmetrically so the number of nodes in each layer will be used in reverse, not repeating the last layer to re encode the features in the autoencoder} + \item{encoder.layers.node.nums}{vector with the number of nodes for each layer when the reducing the feature dimensions within the autoencoder. The autoencoder will be made symmetrically so the number of nodes in each layer will be used in reverse, not repeating the last layer to re encode the features in the autoencoder} \item{autoencoder.activation}{activation function to use in the autoencoder} \item{optimization.loss.function}{loss function used for optimization while fitting the autoencoder} \item{model.file.output.dir}{file location for the autoencoder file} } \value{ \item{autoencoder}{the autoencoder created by the keras package} - \item{autoencoder.file}{the hdf5 file that the model was saved in and can be loaded from} + \item{autoencoder.file}{the keras file that the model was saved in and can be loaded from} } \author{Natalie Fox} \examples{ diff --git a/metadata.yaml b/metadata.yaml index d508c9b..ab85b9a 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -4,5 +4,5 @@ Description: 'Multi-data type subtyping, which is data type agnostic and accepts Maintainers: 'pboutros@mednet.ucla.edu' Contributors: ['Natalie Fox', 'Paul C. Boutros', 'Mao Tian'] Languages: 'R' -Dependencies: ['ConsensusClusterPlus', 'cluster', 'keras', 'tensorflow', 'philentropy'] +Dependencies: ['ConsensusClusterPlus', 'cluster', 'keras3', 'tensorflow', 'philentropy'] References: '' diff --git a/vignettes/iSubGenGuide.Rnw b/vignettes/iSubGenGuide.Rnw index 7d64782..803f32c 100755 --- a/vignettes/iSubGenGuide.Rnw +++ b/vignettes/iSubGenGuide.Rnw @@ -276,7 +276,7 @@ DNA segments can be deleted so there are less than 2 copies. \\ \noindent \textbf{iSubGen:} integrative Subtype Generation. This tool!\\ -\noindent \textbf{Keras R package:} \url{https://cran.r-project.org/package=keras} \\ +\noindent \textbf{keras R package:} \url{https://cran.r-project.org/package=keras} \\ \noindent \textbf{Methylation:} a DNA modification where methyl groups of are added to cytosines in DNA to help regulate DNA transcription. \\