discussion and development of Emacs Snakemake mode
 help / color / mirror / code / Atom feed
* Support R syntax highlighting in R("""-blocks (#6)
@ 2016-04-13  9:03 Endre Bakken Stovner
  2016-04-13 13:26 ` Endre Bakken Stovner
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Endre Bakken Stovner @ 2016-04-13  9:03 UTC (permalink / raw)
  To: kyleam/snakemake-mode

[-- Attachment #1: Type: text/plain, Size: 1855 bytes --]

Uses purcells robust mmm-library: https://github.com/purcell/mmm-mode

Can be further updated to recognize other strings as embedded R. The template should be easy to follow.

I suggest something like `"""[Rr]` for the case where you need to run R-scripts using shell or write them in a variable to print/debug. But I leave it at your discretion.

Use-cases for suggestion above:

```python
        command = """#r
        library(csaw)
        param = readParam(minq=50, restrict=c({chromosomes_as_string}))"""
        print(command)
        R(command)
```

or 

```python
        run_voom_script = """#R
        library(edgeR)
        normfactors = tail(read.table("{input.normalization_file}", row.names=1, header=F), 18)
        colnames(normfactors) = c("norm.factors") # need this name for voom to accept the normfactors
        df = read.table("{input.infile}")

        x = DGEList(counts=df, norm.factors=as.matrix(normfactors))

        y = voom(x)
        write.table(y$E, "{output.outfile}", sep=" ")
        """.format(**locals())

        print(run_voom_script)

        # Must craete new instance of R-interpreter to avoid clashing library requirements
        with open(output.script, "w+") as script_handle:
            script_handle.write(run_voom_script)

        shell("Rscript {output.script}")
```
You can view, comment on, or merge this pull request online at:

  https://github.com/kyleam/snakemake-mode/pull/6

-- Commit Summary --

  * Support R syntax highlighting in R("""-blocks

-- File Changes --

    M snakemake-mode.el (15)

-- Patch Links --

https://github.com/kyleam/snakemake-mode/pull/6.patch
https://github.com/kyleam/snakemake-mode/pull/6.diff

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kyleam/snakemake-mode/pull/6

[-- Attachment #2: Type: text/html, Size: 4129 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-17  0:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13  9:03 Support R syntax highlighting in R("""-blocks (#6) Endre Bakken Stovner
2016-04-13 13:26 ` Endre Bakken Stovner
2016-04-14  5:51 ` Endre Bakken Stovner
2016-04-14  6:09 ` Endre Bakken Stovner
2016-04-17 19:04 ` Endre Bakken Stovner
2016-04-18  4:22 ` Endre Bakken Stovner
2020-04-17  0:01 ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/snakemake-mode/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).