@@ -16,6 +16,7 @@ library(scales)
16
16
data <- read.delim(snakemake @ input [[1 ]],
17
17
header = TRUE ,
18
18
skip = 1 )
19
+ colnames(data ) <- gsub(" ^X" , " " , colnames(data ))
19
20
20
21
# Unique sample conditions
21
22
colnames(data ) <- gsub(" .ext300" , " " , colnames(data ))
@@ -27,7 +28,7 @@ if (length(samples) == 1) {
27
28
colours <- " #1B9E77"
28
29
} else if (length(samples ) == 2 ) {
29
30
colours <- c(" #1B9E77" , " #D95F02" )
30
- } else if (length(genotypes ) > 2 ) {
31
+ } else if (length(samples ) > 2 ) {
31
32
colours <- brewer.pal(length(samples ), " Dark2" )
32
33
}
33
34
names(colours ) <- samples
@@ -84,6 +85,9 @@ df <- data %>%
84
85
mutate(Component = paste0(" PC" , Component )) %> %
85
86
mutate(cumulative_variance = (cumsum(Eigenvalue ) / sum(Eigenvalue ) * 100 * scalefactor ))
86
87
88
+ # Re-level PC factors to ensure correct order
89
+ df $ Component <- factor (df $ Component , levels = df $ Component )
90
+
87
91
# Create scree plot
88
92
s <- ggplot(df , aes(Component , cumulative_variance )) +
89
93
geom_bar(aes(Component , Eigenvalue ),
0 commit comments