FelixTheStudent / cellpypes

Cell type pipes for R
GNU General Public License v3.0
51 stars 3 forks source link

format_rules function #9

Closed FelixTheStudent closed 2 years ago

FelixTheStudent commented 3 years ago

I think readibility is improved if all calls to rule function share the same format. Here is a skeleton:

# skeleton:
obj %>%
  rule(  "A",       "gene1",          ">",   1e-3              )             %>%
  rule(  "A",       "gene1",          ">",   1e-3, parent = "A")             %>%
  rule(  "A",       "gene1",          ">",   1e-3, parent = "A")

Two things might be useful, please experiment with them:

  1. a function that generates above skeleton, so that I can copy-paste it into my R script and start modifying it. Perhaps it is too annoying though to adjust white spaces every time, let's see.
  2. a function that takes an object AFTER the rules were added, and outputs the rules formatted like this. The user could then copy-paste the nicely formatted rules into his Rscript, so that at least after developing the code the script looks nice.

Perhaps think about this more!

FelixTheStudent commented 2 years ago

I solved 1. by writing the pype_code_template(). I'll close this for now, but if anyone thinks 2. is a great idea reopen this issue and I'm tempted to implement it!