Created
August 10, 2020 01:13
-
-
Save mbk0asis/02c22e3c7f0cdb7804a32247cc521289 to your computer and use it in GitHub Desktop.
To add a space to separate groups
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- data.frame(cntNorm2$id_1, | |
mean_WT_PBMC_2m,mean_WT_PBMC_24m,mean_WT_PBMC_28m, | |
mean_HD_PBMC_Young_F, mean_HD_PBMC_Young_M, mean_HD_PBMC_Old_F, mean_HD_PBMC_Old_M) | |
# add a fake column with extremely large value | |
df$empty <- c(rep(100000,nrow(df))) | |
# turns outliers (> upper quatile * 5) into NAs | |
filter_lims <- function(x){ | |
u <- boxplot.stats(x)$stats[5] * 5 | |
for (i in 1:length(x)){ | |
x[i] <- ifelse(x[i]<u, x[i], NA) | |
} | |
return(x) | |
} | |
m_df <- reshape2::melt(df) | |
m_df <- m_df %>% | |
group_by(id) %>% | |
mutate(value2 = filter_lims(value)) # too high values removed from data | |
ggplot(m_df, ...) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment