forked from zacharycompton/cancerAcrossVertebrates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
summexpMin110.R
64 lines (50 loc) · 2.44 KB
/
summexpMin110.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
library(dplyr)
# Read the data from the CSV file
data <- read.csv("415exp.csv")
# Define the desired ranges for the species number
breaks <- c(0, 50, 100, 350)
labels <- c("50", "100", "350") # Corrected to match the specified ranges
# Add a new column for the species number range
data$speciesnumber_range <- cut(data$n, breaks = breaks, labels = labels, include.lowest = TRUE, right = FALSE)
# Filtering the dataset for rows where min is 1
data_points_min1 <- data[data$min == 1, ]
# Calculating the summary statistics with respect to 'speciesnumber_range'
summary_stats <- data_points_min1 %>%
group_by(model, speciesnumber_range) %>%
summarise(
Total = n(),
Negative_Slope_Count = sum(pval >= 0.05 & slope < 0, na.rm = TRUE),
No_Relation_Count = sum(pval <= 0.05 & slope == 0, na.rm = TRUE),
Positive_Slope_Count = sum(pval >= 0.05 & slope > 0, na.rm = TRUE),
.groups = 'drop' # This drops the grouping after summarisation
) %>%
mutate(
Negative_Slope_Percent = paste0(round((Negative_Slope_Count / Total) * 100, 0), "%"),
No_Relation_Percent = paste0(round((No_Relation_Count / Total) * 100, 0), "%"),
Positive_Slope_Percent = paste0(round((Positive_Slope_Count / Total) * 100, 0), "%")
) %>%
select(model, speciesnumber_range, Negative_Slope_Percent, No_Relation_Percent, Positive_Slope_Percent)
# Print the table
print(summary_stats)
write.csv(summary_stats, "./min1experiments.csv")
# Filtering the dataset for rows where min is 1
data_points_min1 <- data[data$min == 10, ]
# Calculating the summary statistics with respect to 'speciesnumber_range'
summary_stats10 <- data_points_min1 %>%
group_by(model, speciesnumber_range) %>%
summarise(
Total = n(),
Negative_Slope_Count = sum(pval >= 0.05 & slope < 0, na.rm = TRUE),
No_Relation_Count = sum(pval <= 0.05 & slope == 0, na.rm = TRUE),
Positive_Slope_Count = sum(pval >= 0.05 & slope > 0, na.rm = TRUE),
.groups = 'drop' # This drops the grouping after summarisation
) %>%
mutate(
Negative_Slope_Percent = paste0(round((Negative_Slope_Count / Total) * 100, 0), "%"),
No_Relation_Percent = paste0(round((No_Relation_Count / Total) * 100, 0), "%"),
Positive_Slope_Percent = paste0(round((Positive_Slope_Count / Total) * 100, 0), "%")
) %>%
select(model, speciesnumber_range, Negative_Slope_Percent, No_Relation_Percent, Positive_Slope_Percent)
# Print the table
print(summary_stats10)
write.csv(summary_stats10, "./min10experiments.csv")