Skip to content

Commit

Permalink
fix problems in Rmd of Chapter 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Accio committed May 21, 2024
1 parent 20738b1 commit 34ab01f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
28 changes: 15 additions & 13 deletions book/07-ligand-based-modelling.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Encoding and similarity search of chemical structures {#cheminfo}

```{r setup, include=FALSE, message=FALSE, warning=FALSE}
```{r setup_chapter7, include=FALSE, message=FALSE, warning=FALSE}
knitr::opts_chunk$set(echo = TRUE,
fig.height=5, fig.width=5)
library(ribiosUtils)
Expand Down Expand Up @@ -215,6 +215,19 @@ ggplot(data=nonld, aes(x=x, y=y, col=z)) +
```

```{r}
set.seed(1887)
library(randomForest)
library(tree)
library(caret)
nonld_train <- sample_frac(nonld, 0.8)
nonld_test <- nonld %>% filter(!index %in% nonld_train$index)
rf <- randomForest(z~., data=nonld_train %>% dplyr::select(-index),
ntree=100)
nonld_test_pred <- predict(rf, nonld_test)
caret::confusionMatrix(nonld_test_pred, nonld_test$z)
```

```{r nonldTrainTest, fig.height=3, fig.width=7}
nonld_train_test <- rbind(cbind(nonld_train, partition="train"),
cbind(nonld_test, partition="test")) %>%
Expand All @@ -229,18 +242,6 @@ ggplot(data=nonld_train_test, aes(x=x, y=y, col=z)) +
panel.background = element_blank())
```

```{r}
set.seed(1887)
library(randomForest)
library(tree)
nonld_train <- sample_frac(nonld, 0.8)
nonld_test <- nonld %>% filter(!index %in% nonld_train$index)
rf <- randomForest(z~., data=nonld_train %>% dplyr::select(-index),
ntree=100)
nonld_test_pred <- predict(rf, nonld_test)
confusionMatrix(nonld_test_pred, nonld_test$z)
```

```{r, fig.height=4, fig.width=4}
{
compactPar()
Expand All @@ -254,6 +255,7 @@ library(reprtree)
reprtree::plot.getTree(rf, k=1)
reprtree::plot.getTree(rf, k=20)
```

```{r}
library(neuralnet)
nonald_train_nn <- nonld_train %>% dplyr::select(-index) %>%
Expand Down
33 changes: 21 additions & 12 deletions book/packages.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ @Manual{R-base
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2020},
year = {2024},
url = {https://www.R-project.org/},
}

@Manual{R-bookdown,
title = {bookdown: Authoring Books and Technical Documents with R Markdown},
author = {Yihui Xie},
year = {2020},
note = {R package version 0.20},
year = {2023},
note = {R package version 0.33},
url = {https://CRAN.R-project.org/package=bookdown},
}

@Manual{R-knitr,
title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
author = {Yihui Xie},
year = {2020},
note = {R package version 1.29},
url = {https://CRAN.R-project.org/package=knitr},
year = {2023},
note = {R package version 1.42},
url = {https://yihui.org/knitr/},
}

@Manual{R-rmarkdown,
title = {rmarkdown: Dynamic Documents for R},
author = {JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone},
year = {2020},
note = {R package version 2.3},
author = {JJ Allaire and Yihui Xie and Christophe Dervieux and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone},
year = {2023},
note = {R package version 2.21},
url = {https://CRAN.R-project.org/package=rmarkdown},
}

Expand All @@ -38,7 +38,7 @@ @Book{bookdown2016
address = {Boca Raton, Florida},
year = {2016},
note = {ISBN 978-1138700109},
url = {https://github.com/rstudio/bookdown},
url = {https://bookdown.org/yihui/bookdown},
}

@Book{knitr2015,
Expand All @@ -60,7 +60,6 @@ @InCollection{knitr2014
publisher = {Chapman and Hall/CRC},
year = {2014},
note = {ISBN 978-1466561595},
url = {http://www.crcpress.com/product/isbn/9781466561595},
}

@Book{rmarkdown2018,
Expand All @@ -69,7 +68,17 @@ @Book{rmarkdown2018
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2018},
note = {ISBN 9781138359338},
isbn = {9781138359338},
url = {https://bookdown.org/yihui/rmarkdown},
}

@Book{rmarkdown2020,
title = {R Markdown Cookbook},
author = {Yihui Xie and Christophe Dervieux and Emily Riederer},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2020},
isbn = {9780367563837},
url = {https://bookdown.org/yihui/rmarkdown-cookbook},
}

0 comments on commit 34ab01f

Please sign in to comment.