Monday, 17 September 2018

Using python with SVG - part 1

Trying to follow the instructions here:
https://jespermaag.github.io/blog/2018/gganatogram/
to help create some more tissues for gganatogram.

Unfortunately fail at first step:
Downloading SVG files using npm install --save anatomogram
This gave an error message...
Similar to this: https://github.com/npm/npm/issues/3190
I think I probably need to reinstall npm
Following this: https://stackoverflow.com/questions/11284634/upgrade-node-js-to-the-latest-version-on-mac-os

using Node -v gives a nice up todate version number v10.10.0

Try again with sudo npm install --save anatomogram
This has worked but gave warnings:
> styled-components@3.4.6 postinstall /Users/paulbrennan/Documents/anatomogram/node_modules/styled-components
> node ./scripts/postinstall.js || exit 0

Use styled-components at work? Consider supporting our development efforts at opencollective.com/styled-components
npm WARN saveError ENOENT: no such file or directory, open '/Users/paulbrennan/Documents/anatomogram/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/Users/paulbrennan/Documents/anatomogram/package.json'
npm WARN anatomogram No description
npm WARN anatomogram No repository field.
npm WARN anatomogram No README data
npm WARN anatomogram No license field.

+ anatomogram@2.0.0
added 21 packages from 24 contributors, updated 1 package, moved 23 packages and audited 102 packages in 21.306s

found 0 vulnerabilities

Checked the file organisation and there are outline SVG files...

At the moment I can only find outlines not organs, etc...

Open PyCharm.
Cut and paste in code...

Hmm, check Python version and packages...
Pauls-MBP-2:anatomogram paulbrennan$ python --version

Python 2.7.10

Should probably update...
Maybe just do this:

Pauls-MBP-2:anatomogram paulbrennan$ python3


Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 

And gives:

>>> 

Test this:
>>> print("Hello world")
Hello world

Works.
Control D to exit (https://apple.stackexchange.com/questions/62164/how-do-i-exit-python-in-the-mountain-lion-terminal)

Wednesday, 12 September 2018

ggplot object test framework....

Not generic but needs to be adapted to the object.
Useful though so here it is...

Adapted from here:
https://github.com/brennanpincardiff/drawProteins/blob/master/tests/testthat/test-geoms.R
with info from here:
https://stackoverflow.com/questions/13457562/how-to-determine-the-geom-type-of-each-layer-of-a-ggplot2-object/43982598#43982598

# testing framework for a ggplot object...

# these are the parts of the ggplot object:
## p$data
## p$layers
## p$scales
## p$mapping
## p$theme
## p$coordinates
## p$facet
## p$plot_env
## p$labels


# confirm its a ggplot
expect_is(ggseg(),c("gg","ggplot"))

p <- ggseg()

# should be a list of 9
# a ggplot object should be a list of 9
expect_equal(mode(p), "list")
expect_equal(length(p), 9)

## p$data
expect_equal(dim(p$data)[1], 10913)
expect_equal(dim(p$data)[2], 11)
expect_equal(colnames(p$data)[1], "long")

## p$layers
# should have a defined number of layers
expect_equal(length(p$layers), 1)
# https://stackoverflow.com/questions/13457562/how-to-determine-the-geom-type-of-each-layer-of-a-ggplot2-object/43982598#43982598
# layer should be a specific geom
expect_equal(class(p$layers[[1]]$geom)[1], "GeomPolygon")
# if there are multiple layers we can test more than one...

## p$labels
# should have x but not y labels
expect_equal(p$labels$x, "hemisphere")
expect_equal(p$labels$y, "")

Worked through adding tests to gganatogram...

Workflow


  1. Fork (online)
  2. Open in R-Studio - as a git repository
  3. Check the build before going forward (devtools::check())
  4. Write a test
  5. Run tests using R-Studio
  6. 19 different tests run today.
  7. Check the build again at the end - R-Studio tabs worked
  8. Commit in R-Studio
  9. Push to Github in R-Studio
  10. Create Pull Request online 
  11. Feel happy with some high quality coding done :-)


Used R-Studio for it all - advice from here (http://r-bio.github.io/intro-git-rstudio/) very useful.


Tuesday, 11 September 2018

Drawing bodies, brains and protein structures...

Bodies

ggplot for bodies with expression data...
https://twitter.com/JesperMaag/status/1038914309957607424

https://github.com/jespermaag/gganatogram

https://github.com/ebi-gene-expression-group/anatomogram


Semantic Body Illustrations 
https://github.com/flekschas/sbi
https://academic.oup.com/bioinformatics/article/31/5/794/2748201
http://sbb.cellfinder.org/human-adult-female-body

Brains

https://github.com/LCBC-UiO/ggseg
https://github.com/LCBC-UiO/ggseg/wiki/Creating-and-contributing-atlases



https://rud.is/b/2016/02/11/plot-the-new-svg-r-logo-with-ggplot2/

Most importantly:
https://github.com/davidmcclure/svg-to-wkt
Convert SVG into text....


https://drmowinckels.io/blog/adding-external-images-to-plots/



And then proteins too...

http://thegrantlab.org/bio3d/index.php

Bio3D is an R package containing utilities for the analysis of protein structure, sequence and trajectory data.

https://www.rcsb.org/3d-view/1AYC




But still SVG to data.frame to plot...
I don't know the way!
https://github.com/davidmcclure/svg-to-wkt - maybe!

Info here: https://github.com/LCBC-UiO/ggseg/wiki/Creating-and-contributing-atlases


Thursday, 30 August 2018

I want to try to push my development version to Bioconductor...

https://bioconductor.org/developers/how-to/git/push-to-github-bioc/

Tried but failed.
This is the message:

v3431-0a7785bc:drawProteins paulbrennan$ git push upstream devel
Counting objects: 68, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (65/65), done.
Writing objects: 100% (68/68), 14.42 KiB | 2.88 MiB/s, done.
Total 68 (delta 39), reused 0 (delta 0)
remote: FATAL: W refs/heads/devel packages/drawProteins brennanpincardiff DENIED by fallthru
remote: error: hook declined to update refs/heads/devel
To git.bioconductor.org:packages/drawProteins.git
 ! [remote rejected] devel -> devel (hook declined)
error: failed to push some refs to 'git@git.bioconductor.org:packages/drawProteins.git'
v3431-0a7785bc:drawProteins paulbrennan$ 



I wonder why?
Does bumping version number make a difference?

No hook declined.


Very helpful answer back from Lori:

Bioconductor assumes the master branch of a github repository is the devel branch.  There is no devel branch on the git.bioconductor server so you will have to push the changes to upstream master.  This is slightly confusing but stated on the git help pages


http://bioconductor.org/developers/how-to/git/


http://bioconductor.org/developers/how-to/git/push-to-github-bioc/


Merging master into devel branches....

So I found that I had made changes to devel but I was using an old branch of devel that was different from the master.

This was not ideal so I tried to "Update from Master" using Github Desktop.
This created conflicts in DESCRIPTION, NEWS and README.Rmd.

To resolve the conflicts, I opened the files in R-Studio and edited them in the way I thought was necessary using advice from here:
https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/

Then I used git add, i.e. git add DESCRIPTION after the file was updated to resolve the conflict and the conflict markers.

Finally I typed: 
git commit -m "Updating devel from master and resolving conflicts"

to resolve the whole thing. 
This allowed me to update devel all from master and only has the changes in the devel since I started working on it this month (August)

All in all a successful use of Git, I think.