R-tutors code / report

There is a html version in the repo.

R code below was generated by GPT4.0

### 0. Read File
```{R, eval = FALSE}
df <- read.csv("reactome results awg puedo time series - result.csv")
```
```{R, echo = FALSE}
df <- params$df
df2 <- params$df2
```


### 1.  can you make a bar chart showing the pathway name with the length of the bar determined by "#Reactions found" plotted next to another bar for the "#Reactions total" 
 GPT-4 Turbo (11/23) (Temperature=0.2)
```{R}

library(ggplot2)

# Assuming 'pathway_name' is a column in df that contains the names of the pathways.
# If the column has a different name, replace 'pathway_name' with the correct column name.

# Create a long format data frame for plotting with ggplot2
df_long <- reshape2::melt(df, id.vars = "pathway_name", measure.vars = c("x_reactions_found", "x_reactions_total"))

# Create the bar chart
ggplot(df_long, aes(x = pathway_name, y = value, fill = variable)) +
  geom_bar(stat = "identity", position = "dodge") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x = "Pathway Name", y = "Number of Reactions", fill = "Measure") +
  scale_fill_manual(values = c("x_reactions_found" = "blue", "x_reactions_total" = "red"))

```


### 2.  can you make a bar chart showing the pathway name with the length of the bar determined by "#Reactions found" plotted next to another bar for the "#Reactions total". only show data for the 20 top "Pathway names" that have the largest "#Entities". 
 GPT-4 Turbo (11/23) (Temperature=0.2)
```{R}

library(ggplot2)
library(dplyr)

# Assuming 'pathway_name' is a column in df that contains the names of the pathways.
# If the column has a different name, replace 'pathway_name' with the correct column name.
# Also assuming that "#Entities" refers to 'x_entities_found'.
# If it refers to a different column, replace 'x_entities_found' with the correct column name.

# Filter the top 20 pathways with the largest "#Entities"
top_pathways <- df %>%
  arrange(desc(x_entities_found)) %>%
  slice(1:20)

# Create a long format data frame for plotting with ggplot2
top_pathways_long <- reshape2::melt(top_pathways, id.vars = "pathway_name", measure.vars = c("x_reactions_found", "x_reactions_total"))

# Create the bar chart for the top 20 pathways
ggplot(top_pathways_long, aes(x = reorder(pathway_name, value), y = value, fill = variable)) +
  geom_bar(stat = "identity", position = "dodge") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x = "Pathway Name", y = "Number of Reactions", fill = "Measure") +
  scale_fill_manual(values = c("x_reactions_found" = "blue", "x_reactions_total" = "red"))

```


### 4.  can you make a normalized bar chart showing the pathway name with the length of the bar determined by "#Reactions found" plotted next to another bar for the "#Reactions total". only show data for the 20 top "Pathway names" that have the largest "#Entities". 
 GPT-4 Turbo (11/23) (Temperature=0.2)
```{R}
library(ggplot2)
library(dplyr)

# Assuming 'pathway_name' is a column in df that contains the names of the pathways.
# If the column has a different name, replace 'pathway_name' with the correct column name.
# Also assuming that "#Entities" refers to 'x_entities_found'.
# If it refers to a different column, replace 'x_entities_found' with the correct column name.

# Filter the top 20 pathways with the largest "#Entities"
top_pathways <- df %>%
  arrange(desc(x_entities_found)) %>%
  slice(1:20)

# Normalize the reactions found and total by dividing by the maximum value in the subset
top_pathways$x_reactions_found_normalized <- top_pathways$x_reactions_found / max(top_pathways$x_reactions_found)
top_pathways$x_reactions_total_normalized <- top_pathways$x_reactions_total / max(top_pathways$x_reactions_total)

# Create a long format data frame for plotting with ggplot2
top_pathways_long_normalized <- reshape2::melt(top_pathways, id.vars = "pathway_name", measure.vars = c("x_reactions_found_normalized", "x_reactions_total_normalized"))

# Create the normalized bar chart for the top 20 pathways
ggplot(top_pathways_long_normalized, aes(x = reorder(pathway_name, value), y = value, fill = variable)) +
  geom_bar(stat = "identity", position = "dodge") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x = "Pathway Name", y = "Normalized Number of Reactions", fill = "Measure") +
  scale_fill_manual(values = c("x_reactions_found_normalized" = "blue", "x_reactions_total_normalized" = "red"))
```


### 5.  can you make a bar chart showing the pathway name with the length of the bar determined by the percentage of reactions changes calculated by dividing the "#Reactions found" by the "#Reactions total" and multiplying by 100. only show data for the 20 top "Pathway names" that have the largest "#Entities". 
 GPT-4 Turbo (11/23) (Temperature=0.2)
```{R}
library(ggplot2)
library(dplyr)

# Assuming 'pathway_name' is a column in df that contains the names of the pathways.
# If the column has a different name, replace 'pathway_name' with the correct column name.
# Also assuming that "#Entities" refers to 'x_entities_found'.
# If it refers to a different column, replace 'x_entities_found' with the correct column name.

# Filter the top 20 pathways with the largest "#Entities"
top_pathways <- df %>%
  arrange(desc(x_entities_found)) %>%
  slice(1:20)

# Calculate the percentage of reactions changes
top_pathways$reactions_percentage_change <- (top_pathways$x_reactions_found / top_pathways$x_reactions_total) * 100

# Create the bar chart for the top 20 pathways
ggplot(top_pathways, aes(x = reorder(pathway_name, reactions_percentage_change), y = reactions_percentage_change)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x = "Pathway Name", y = "Percentage of Reactions Change")
```


### 7.  can you make a Lollipop Chart showing the pathway name with the length of the bar determined by the percentage of reactions changes calculated by dividing the "#Reactions found" by the "#Reactions total" and multiplying by 100. only show data for the 20 top "Pathway names" that have the largest "#Entities". 
 GPT-4 Turbo (11/23) (Temperature=0.2)
```{R}
library(ggplot2)
library(dplyr)

# Assuming 'pathway_name' is a column in df that contains the names of the pathways.
# If the column has a different name, replace 'pathway_name' with the correct column name.
# Also assuming that "#Entities" refers to 'x_entities_found'.
# If it refers to a different column, replace 'x_entities_found' with the correct column name.

# Filter the top 20 pathways with the largest "#Entities"
top_pathways <- df %>%
  arrange(desc(x_entities_found)) %>%
  slice(1:20)

# Calculate the percentage of reactions changes
top_pathways$reactions_percentage_change <- (top_pathways$x_reactions_found / top_pathways$x_reactions_total) * 100

# Create the Lollipop Chart for the top 20 pathways
ggplot(top_pathways, aes(x = reorder(pathway_name, reactions_percentage_change), y = reactions_percentage_change)) +
  geom_segment(aes(x = pathway_name, xend = pathway_name, y = 0, yend = reactions_percentage_change), color = "gray") +
  geom_point(size = 3, color = "steelblue") +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  labs(x = "Pathway Name", y = "Percentage of Reactions Change")
```

interacts_withx_interactors_totalinteracts_with<None>

Last updated