Hi @zx8754,
I was trying a test run with your R code to understand further, however I keep getting the syntax errors. Am I missing something here.
dash <- d %>%
arrange(Genes, Timepoints) %>%
group_by(Genes) %>%
mutate(x1 = if_elseis.na(value), lag(Timepoints), factor(NA)),
x2 = if_elseis.na(value), lead(Timepoints), factor(NA)),
y1 = if_elseis.na(value), lag(value), NA_real_),
y2 = if_elseis.na(value), lead(value), NA_real_)) %>%
filter(!is.na(y1) & !is.na(y2))
dash <- d %>%
+ arrange(Genes, Timepoints) %>%
+ group_by(Genes) %>%
+ mutate(x1 = if_elseis.na(value), lag(Timepoints), factor(NA)),
Error: unexpected ',' in:
" group_by(Genes) %>%
mutate(x1 = if_elseis.na(value), lag(Timepoints), factor(NA)),"
> x2 = if_elseis.na(value), lead(Timepoints), factor(NA)),
Error: unexpected ',' in "x2 = if_elseis.na(value),"
> y1 = if_elseis.na(value), lag(value), NA_real_),
Error: unexpected ',' in "y1 = if_elseis.na(value),"
> y2 = if_elseis.na(value), lead(value), NA_real_)) %>%
Error: unexpected ',' in "y2 = if_elseis.na(value),"
> filter(!is.na(y1) & !is.na(y2))
Error in filter(!is.na(y1) & !is.na(y2)) : object 'y1' not found
>
str(d)
'data.frame': 44 obs. of 4 variables:
$ Genes : Factor w/ 8 levels "Gene_A","Gene_B",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Timepoints: Factor w/ 20 levels "T1","T2","T3",..: 1 2 8 9 10 11 12 16 17 18 ...
$ value : num -1.556 -3.085 -0.721 -0.901 NA ...
$ X12 : Factor w/ 2 levels "M10.1","M10.2": 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "names")= chr "Gene_A" "Gene_A" "Gene_A" "Gene_A" ...


Can you post a snippet of the data used to generate that graph? For such an issue a reproducible example is required to properly troubleshoot.
Hello mohammedtoufiq91!
It appears that your post has been cross-posted to another site: https://support.bioconductor.org/p/126702/
This is typically not recommended as it runs the risk of annoying people in both communities.
@ ATpoint,
Apologies for the confusion. This would not be repeated going forward.