@@ -146,15 +146,15 @@ plot_csre <- function(
146
146
diff <- groupavg %> %
147
147
# join group avarage and total explained avarage
148
148
# and add the total_expr column giving the total expression across cells
149
- inner_join(total_explained %> % rename(total_expr = avgexpr ), by = c(" group" , " gene" )) %> %
149
+ inner_join(total_explained %> % dplyr :: rename(total_expr = avgexpr ), by = c(" group" , " gene" )) %> %
150
150
# give avgexpr, avgreg and total_expr separate columns for both bulkgroups A and B
151
151
pivot_wider(names_from = group , values_from = c(avgexpr , avgregulation , total_expr ), names_prefix = " group_" , values_fill = 0.0 ) %> %
152
- rename(avgexpr_A = paste0(" avgexpr_group_" , groupA )) %> %
153
- rename(avgexpr_B = paste0(" avgexpr_group_" , groupB )) %> %
154
- rename(avgregulation_A = paste0(" avgregulation_group_" , groupA )) %> %
155
- rename(avgregulation_B = paste0(" avgregulation_group_" , groupB )) %> %
156
- rename(total_expr_A = paste0(" total_expr_group_" , groupA )) %> %
157
- rename(total_expr_B = paste0(" total_expr_group_" , groupB )) %> %
152
+ dplyr :: rename(avgexpr_A = paste0(" avgexpr_group_" , groupA )) %> %
153
+ dplyr :: rename(avgexpr_B = paste0(" avgexpr_group_" , groupB )) %> %
154
+ dplyr :: rename(avgregulation_A = paste0(" avgregulation_group_" , groupA )) %> %
155
+ dplyr :: rename(avgregulation_B = paste0(" avgregulation_group_" , groupB )) %> %
156
+ dplyr :: rename(total_expr_A = paste0(" total_expr_group_" , groupA )) %> %
157
+ dplyr :: rename(total_expr_B = paste0(" total_expr_group_" , groupB )) %> %
158
158
# for each row (comprising gene,celltype) give logp1 difference of avgexpr, avgreg and total_expr
159
159
mutate(logdiffexpr = log2((avgexpr_A + 1.0 ) / (avgexpr_B + 1.0 ))) %> %
160
160
mutate(logdiffreg = log2((avgregulation_A + 1.0 ) / (avgregulation_B + 1.0 ))) %> %
@@ -237,7 +237,7 @@ plot_csre <- function(
237
237
mutate(logexpr = log2(avgexpr + 1.0 )) %> %
238
238
dplyr :: select(- avgexpr ) %> %
239
239
pivot_wider(names_from = group , values_from = logexpr ) %> %
240
- rename(group_A = groupA , group_B = groupB ) %> %
240
+ dplyr :: rename(group_A = groupA , group_B = groupB ) %> %
241
241
mutate(logdiff = group_A - group_B ) %> %
242
242
ggplot(aes(x = logdiff , y = factor (gene , rev(ord_genes )))) +
243
243
geom_bar(stat = " identity" , position = " stack" ) +
@@ -258,7 +258,7 @@ plot_csre <- function(
258
258
filter(celltype != " total_explained" ) %> %
259
259
# give both groups their own column
260
260
pivot_wider(names_from = group , values_from = avgexpr , values_fill = 0 ) %> %
261
- rename(group_A = all_of(groupA ), group_B = all_of(groupB )) %> %
261
+ dplyr :: rename(group_A = all_of(groupA ), group_B = all_of(groupB )) %> %
262
262
group_by(gene ) %> %
263
263
# cumulate the avgexpr for each gene in the relgroup across celltypes
264
264
mutate(normsum = sum(.data [[relgroup ]])) %> %
0 commit comments