Skip to content

Commit 2cfad57

Browse files
author
Paul Huettl
committed
fixed dplyr masking
1 parent 19fd3c1 commit 2cfad57

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

R/cell_proportions.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ cell_proportions_singlemodel <- function(
8080
mutate(wsum=sum(weight)) %>%
8181
# discard redundant entries
8282
dplyr::select(dplyr::all_of(c(bulk_id, by, "wsum"))) %>% unique() %>%
83-
rename(weight = wsum)
83+
dplyr::rename(weight = wsum)
8484
return(props)
8585
}
8686

@@ -161,7 +161,7 @@ cell_proportions <- function(
161161
by,
162162
weight,
163163
bulk_id,
164-
cell_id) %>% rename (tmpweight_boot = weight)
164+
cell_id) %>% dplyr::rename (tmpweight_boot = weight)
165165
for( irun in 2:tissuemodel$bootstrap_nruns ){
166166
message(paste0("Computing cell proportions for bootstrap sample ", irun, " / ", tissuemodel$bootstrap_nruns))
167167
# fetch the tissuemodel of the irun-th bootstrap run
@@ -175,7 +175,7 @@ cell_proportions <- function(
175175
by,
176176
weight,
177177
bulk_id,
178-
cell_id) %>% rename(current_weight = weight)
178+
cell_id) %>% dplyr::rename(current_weight = weight)
179179
# join the bootstrapped cell population weights as list to the props dataframe
180180
# within a column "tmpweight_boot"
181181
props <- props %>%
@@ -190,11 +190,11 @@ cell_proportions <- function(
190190

191191
props <- props %>%
192192
mutate(tmpweight = mean(tmpweight_boot)) %>%
193-
# rename tmpweight with weight and tmp_boot with weight_boot
194-
rename(!!weight := tmpweight, !!paste0(weight, "_boot") := tmpweight_boot)
193+
# dplyr::rename tmpweight with weight and tmp_boot with weight_boot
194+
dplyr::rename(!!weight := tmpweight, !!paste0(weight, "_boot") := tmpweight_boot)
195195
# quoname is deprecated
196-
# rename(!!quo_name(weight) := tmpweight) %>%
197-
# rename(!!quo_name(paste0(weight, "_boot")) := tmpweight_boot)
196+
# dplyr::rename(!!quo_name(weight) := tmpweight) %>%
197+
# dplyr::rename(!!quo_name(paste0(weight, "_boot")) := tmpweight_boot)
198198
return(props)
199199
} else {
200200
return(cell_proportions_singlemodel(tissuemodel, mapping, by, weight, bulk_id, cell_id))

R/cse_visualization.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ plot_csre <- function(
146146
diff <- groupavg %>%
147147
# join group avarage and total explained avarage
148148
# 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")) %>%
150150
# give avgexpr, avgreg and total_expr separate columns for both bulkgroups A and B
151151
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)) %>%
158158
# for each row (comprising gene,celltype) give logp1 difference of avgexpr, avgreg and total_expr
159159
mutate(logdiffexpr = log2((avgexpr_A+1.0) / (avgexpr_B+1.0))) %>%
160160
mutate(logdiffreg = log2((avgregulation_A+1.0) / (avgregulation_B+1.0))) %>%
@@ -237,7 +237,7 @@ plot_csre <- function(
237237
mutate(logexpr = log2(avgexpr+1.0)) %>%
238238
dplyr::select(-avgexpr) %>%
239239
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) %>%
241241
mutate(logdiff=group_A-group_B) %>%
242242
ggplot(aes(x=logdiff, y=factor(gene, rev(ord_genes)))) +
243243
geom_bar(stat="identity", position="stack") +
@@ -258,7 +258,7 @@ plot_csre <- function(
258258
filter(celltype != "total_explained") %>%
259259
# give both groups their own column
260260
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)) %>%
262262
group_by(gene) %>%
263263
# cumulate the avgexpr for each gene in the relgroup across celltypes
264264
mutate(normsum = sum(.data[[relgroup]])) %>%

R/specific_expression.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ specific_expression_regulation <- function(
236236
dplyr::select(-expression.x, -expression.y, -regulation.x, -regulation.y)
237237
}
238238
# add column storing mean over all bootstrapped expressions and regulations
239-
csre <- csre %>% rename(expression_boot = expression) %>%
239+
csre <- csre %>% dplyr::rename(expression_boot = expression) %>%
240240
mutate(expression = mean(expression_boot)) %>%
241-
rename(regulation_boot = regulation) %>%
241+
dplyr::rename(regulation_boot = regulation) %>%
242242
mutate(regulation = mean(regulation_boot))
243243
return(csre)
244244
} else {

R/weight_visualization.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ plot_element_differential_density <- function(
488488
# give each group a separate column
489489
pivot_wider(names_from=all_of(group), values_from=all_of(z), names_prefix="group_") %>%
490490
# give both groups the names specified by the input groups
491-
rename(groupA = all_of(paste0("group_", groupA))) %>%
492-
rename(groupB = all_of(paste0("group_", groupB))) %>%
491+
dplyr::rename(groupA = all_of(paste0("group_", groupA))) %>%
492+
dplyr::rename(groupB = all_of(paste0("group_", groupB))) %>%
493493
# store the differential density between groupA and groupB in the column diff
494494
mutate(diff = groupA - groupB) %>%
495495
# delete the seperate densities and keep only the differential density

0 commit comments

Comments
 (0)