Skip to content
This repository has been archived by the owner on Mar 3, 2021. It is now read-only.

Commit

Permalink
preparing release for re-submission.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aariq committed Jun 30, 2020
1 parent 98642b7 commit 8f2cba5
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 432 deletions.
1 change: 1 addition & 0 deletions R/2-muir-analysis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ patchwork <-
patchwork
ggsave(here("out", "muir-biplots.png"), width = 9, height = 4)
# ggsave(here("out", "muir-biplots.pdf"), width = 9, height = 4)
```


Expand Down
4 changes: 4 additions & 0 deletions R/6-simulation-figures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ apparent.cor.p <- apparent.cor.p + theme(legend.position = "none")
# tag_suffix = ")"
)
ggsave(here("out", "three-scenarios.png"), width = 9.5, height = 8.5)
# ggsave(here("out", "three-scenarios.eps"), width = 9.5, height = 8.5)
# ggsave(here("out", "three-scenarios.pdf"), width = 9.5, height = 8.5)
```

# Biplots
Expand Down Expand Up @@ -419,6 +421,8 @@ I think I want 4 panels, PCA on the top, PLS on the bottom, apparent on the left
legend.position = "none", plot.title = element_text(hjust=0.5, vjust = 9)) &
plot_annotation(tag_levels = "A")
ggsave(here("out", "simulation biplots.png"))
# ggsave(here("out", "simulation biplots.eps"))
# ggsave(here("out", "simulation biplots.pdf"))
```


80 changes: 2 additions & 78 deletions R/mini-review.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(here)
library(googlesheets4)
library(googledrive)
library(rcrossref)
#for venn diagram
library(ggforce)
library(limma)
Expand All @@ -43,83 +40,13 @@ Search terms:
- first round: PCA OR PLS OR "principal component" OR "partial least squares" OR "partial least square"
- second round: RDA or "redundancy analysis"

# Purpose

To pull my mini review table from google sheets, get full citations from DOIs in URLs, extract the year, and re-upload.

# Get sheet

```{r}
review_id <- drive_get(id = "1W5ChtX-bKpJJL8-znfeCWFeuenM7btjL9XUD2nxDxnE")
sheets_get(review_id)
sheets_sheets(review_id)
df <- read_sheet(review_id, "Mini-review", col_types = "ccnccccccccccc")
```

# Get Citations from DOI

Extract the DOI from the URL

```{r}
df2 <-
df %>%
mutate(doi = str_extract(url, "10\\..+"))
#check for duplicate rows
any(duplicated(df2$doi))
```

Get citations and year for any entries without them

```{r}
safe_cr_cn <- possibly(cr_cn, NA)
df3 <-
df2 %>%
mutate(citation = ifelse(is.na(citation),
safe_cr_cn(doi, format = "text", style = "apa"),
citation))
df4 <-
df3 %>%
unnest(citation) %>%
mutate(year = ifelse(is.na(year),
str_extract(citation, "\\d{4}"),
year)) %>%
select(-doi, -pca_use_old)
head(df4)
```

## Write "raw" data locally and update google sheet.

```{r}
write_csv(df4, here::here("data", "mini-review.csv"))
```
```{r}
write_sheet(df4, "1W5ChtX-bKpJJL8-znfeCWFeuenM7btjL9XUD2nxDxnE", sheet = "out")
```


# Create supplementary and summary tables


Filter by year, write to .csv as a supplementary table

```{r}
df_supp <-
df4 %>%
filter(year == 2018) %>%
#remove studies that don't use at least one of the three methods.
filter_at(vars(pls_use, rda_use, pca_use), any_vars(!is.na(.)))
write_excel_csv(df_supp, here("out", "TableS1.csv"), na = " ")
```

# Explore and create Table

To skip the wrangling above and just re-run these analyses:

```{r}
df_supp <- read_csv(here::here("out", "TableS1.csv"))
df_supp <- read_csv(here::here("data", "mini-review.csv"))
```

## How many papers total and broken down by journal?
Expand Down Expand Up @@ -192,8 +119,6 @@ ggplot(df.venn, aes(x0 = x, y0 = y, r = 1.5, fill = labels)) +
```




## How is PLS used?

```{r}
Expand Down Expand Up @@ -280,14 +205,13 @@ bind_rows(pls_use, rda_use, pca_use, pc_variable_use, supervised_alt) %>%
write_csv(here("out", "review-table-rough.csv"))
```



## How often are other multivariate methods used?

```{r}
df_supp %>%
filter(!is.na(other_supervised)) %>% count()
```

## How manuy uses of each "other" supervised method, etc.

```{r}
Expand Down
354 changes: 131 additions & 223 deletions data/mini-review.csv

Large diffs are not rendered by default.

131 changes: 0 additions & 131 deletions out/TableS1.csv

This file was deleted.

Binary file removed out/TableS1.xlsx
Binary file not shown.
Binary file modified out/muir-biplots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified out/simulation biplots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8f2cba5

Please sign in to comment.