{"action":"created","comment":{"url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/comments/45084399","id":45084399,"diff_hunk":"@@ -1,92 +1,30 @@\n-library(gplots)\n+library(jsonlite)\n+library(reshape2)\n \n-\n-dataset1color <- \"coral3\"\n-dataset2color <- \"chartreuse3\"\n-labelColumns <- c(\"Row.Label\",\"Bio.marker\")\n-MAX_ROWS <- 50 # this will be made into an argument after the prototype\n-\n-#Input expected 1 or 2 dataframes with columns: Row.Label, Bio.marker, ASSAY_0001 ASSAY_0002 ...\n-# In the prorotype we do not use biomarker yet\n main <- function(){\n-  datasets <- parseInput(loaded_variables) #Hardcoded input parsing - only for the prototype\n-  measurements <- extractMeasurements(datasets) #extract the numeric part - as a numeric matrix is needed for the heatmap.2 function\n-  humanReadableNames <-extractNames(datasets)\n-  measurements <- assignNames(measurements,humanReadableNames) #combine label with Biomarker(if present) and assign as a name to be displayed on the heatmap\n-#  measurements <- transform(measurements) #log2 transform the numerical matrix with measurements\n-  grouping <- extractGrouping(datasets) #Grouping determines coloring of the samples - one color for dataset1 and a different one for dataset2\n-  makeHeatmap(measurements,grouping) # plot the heatmap and save it in the working directory as a .png file\n-}\n-\n-parseInput <- function(variables){\n-  onlyTwo <- variables[1:2]\n-  onlyTwo[[1]] <- variables[[1]][1:MAX_ROWS,]\n-  onlyTwo <- onlyTwo[!sapply(onlyTwo, is.null)]\n-  if(length(onlyTwo) == 2){\n-    onlyTwo[[2]] <- variables[[2]][1:MAX_ROWS,]\n-  }\n-  return(onlyTwo)\n-}\n-\n-extractGrouping <- function(datasets){\n-  ds1Length <- ncol(datasets[[1]]) - length(labelColumns)\n-  grouping <- rep(dataset1color,ds1Length)\n-  if(length(datasets) > 1){\n-    ds2Length <- ncol(datasets[[2]]) - length(labelColumns)\n-    secondSetGrouping <- rep(dataset2color,ds2Length)\n-    grouping <- c(grouping,secondSetGrouping)\n-  }\n-  return(grouping)\n-}\n-\n-extractMeasurements <- function(datasets){\n-  measurements <- extractMeasurement(datasets[[1]])\n-  if(length(datasets) > 1){\n-    secondDsMeasurements <-extractMeasurement(datasets[[2]])\n-    measurements <- cbind(measurements,secondDsMeasurements)\n-  }\n-  return(measurements)\n-}\n-\n-extractMeasurement <- function(dataset){\n-  measurements  <- subset(dataset,select=-c(Row.Label,Bio.marker)) # this will select all columns other than Row.Label,Bio.marker columns\n-  measurements  <- data.matrix(measurements)\n-}\n-\n-assignNames <- function(measurements, humanReadableRowNames){\n-  rownames(measurements) <- humanReadableRowNames\n-  return(measurements)\n-}\n-\n-extractNames <- function(datasets){\n-  humanReadableNames <- datasets[[1]]$Row.Label\n-  #  if(length(datasets) > 1){\n-  #    namesSecondDs <- datasets[[2]]$Row.Label\n-  #    humanReadableNames <- c(humanReadableNames, namesSecondDs)\n-  #  }\n-  return(humanReadableNames)\n-}\n-\n-\n-transform <- function(measurements){\n-  measurements <- log(measurements,2)\n-}\n-\n-makeHeatmap <- function(measurements,grouping){\n-  png(filename=\"heatmap.png\", width = 800, height = 800)\n-  breakpoints <- seq(from= -2,to = 10,length.out=75) # this will clamp all values below 0.1\n-  breakpoints <- c(-10, breakpoints) # number of breaks must equal number of colors +1\n-  heatmap.2(measurements,\n-            scale = \"none\",\n-            dendrogram = \"none\",\n-            Rowv = NA,\n-            Colv = NA,\n-            density.info = \"none\",\n-            trace = \"none\",\n-            col=redgreen(75),\n-            margins=c(12,12),\n-            ColSideColors= as.character(grouping),\n-            breaks = breakpoints\n-  )\n-  dev.off()\n+   df <- loaded_variables[[1]] # SmartR does not support multiple HDD nodes yet\n+   fields <- buildFields(df)\n+   geneSymbols <- unique(fields[\"GENESYMBOL\"])[,1] #[,1] in order to get a vector, otherwise we get a dataframe\n+   patientIDs <-unique(fields[\"PATIENTID\"])[,1]\n+   probes <- unique(fields[\"PROBE\"])[,1]\n+   significanceValues <- unique(fields[\"SIGNIFICANCE\"])[,1]\n+   jsn <- toJSON(list(\"fields\"=fields, \"geneSymbols\"=geneSymbols, \n+               \"patientIDs\"=patientIDs,\n+               \"probes\"=probes,\n+               \"significanceValues\"=significanceValues ),\n+          pretty = TRUE)\n+   write(jsn,file = \"heatmap.json\") # json file be served the same way like any other file would - get name via /status call and then /download\n+}\n+\n+\n+\n+buildFields <- function(df){\n+  df <- melt(df,id=names(df)[1:2])\n+  SIGNIFICANCE <- rep(1.0, nrow(df))\n+  raw <- df[,ncol(df)]\n+  ZSCORE <- (raw - mean(raw))/ sd(raw)","path":"web-app/HeimScripts/heatmap/run.r","position":114,"original_position":114,"commit_id":"d93ceaa99659f058cba495956ed04cb1b6514cb6","original_commit_id":"d93ceaa99659f058cba495956ed04cb1b6514cb6","user":{"login":"RianneJ","id":6952296,"avatar_url":"https://avatars.githubusercontent.com/u/6952296?v=3","gravatar_id":"","url":"https://api.github.com/users/RianneJ","html_url":"https://github.com/RianneJ","followers_url":"https://api.github.com/users/RianneJ/followers","following_url":"https://api.github.com/users/RianneJ/following{/other_user}","gists_url":"https://api.github.com/users/RianneJ/gists{/gist_id}","starred_url":"https://api.github.com/users/RianneJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RianneJ/subscriptions","organizations_url":"https://api.github.com/users/RianneJ/orgs","repos_url":"https://api.github.com/users/RianneJ/repos","events_url":"https://api.github.com/users/RianneJ/events{/privacy}","received_events_url":"https://api.github.com/users/RianneJ/received_events","type":"User","site_admin":false},"body":"zscores are now calculated over the whole set of values (pooling all measurements from all genes), instead of per gene. Shouldn't it be done per gene?","created_at":"2015-11-17T16:45:32Z","updated_at":"2015-11-17T16:45:32Z","html_url":"https://github.com/thehyve/heim-SmartR/pull/25#discussion_r45084399","pull_request_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/comments/45084399"},"html":{"href":"https://github.com/thehyve/heim-SmartR/pull/25#discussion_r45084399"},"pull_request":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25","id":50961307,"html_url":"https://github.com/thehyve/heim-SmartR/pull/25","diff_url":"https://github.com/thehyve/heim-SmartR/pull/25.diff","patch_url":"https://github.com/thehyve/heim-SmartR/pull/25.patch","issue_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/25","number":25,"state":"open","locked":false,"title":"Json output heatmap","user":{"login":"PiotrZakrzewski","id":1050269,"avatar_url":"https://avatars.githubusercontent.com/u/1050269?v=3","gravatar_id":"","url":"https://api.github.com/users/PiotrZakrzewski","html_url":"https://github.com/PiotrZakrzewski","followers_url":"https://api.github.com/users/PiotrZakrzewski/followers","following_url":"https://api.github.com/users/PiotrZakrzewski/following{/other_user}","gists_url":"https://api.github.com/users/PiotrZakrzewski/gists{/gist_id}","starred_url":"https://api.github.com/users/PiotrZakrzewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PiotrZakrzewski/subscriptions","organizations_url":"https://api.github.com/users/PiotrZakrzewski/orgs","repos_url":"https://api.github.com/users/PiotrZakrzewski/repos","events_url":"https://api.github.com/users/PiotrZakrzewski/events{/privacy}","received_events_url":"https://api.github.com/users/PiotrZakrzewski/received_events","type":"User","site_admin":false},"body":"This is a first step towards reimplementing the way R scripts are handled. \r\nIt is meant to be integrated with D3 visualizations from Sascha - it generates JSON which  follows the same format as original SmartR does. \r\nAfter successful integration I will simplify the JSON produced by the script. \r\nOther pending features:\r\n- Add limma ranking of genes\r\n- Add settings: so that parameters can be passed from UI: max number of rows, projection, ranking method","created_at":"2015-11-17T15:32:47Z","updated_at":"2015-11-17T16:45:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7095ded31ec966856a3cd4c3e10675057a28f148","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25/commits","review_comments_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25/comments","review_comment_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/25/comments","statuses_url":"https://api.github.com/repos/thehyve/heim-SmartR/statuses/d93ceaa99659f058cba495956ed04cb1b6514cb6","head":{"label":"thehyve:json-output-heatmap","ref":"json-output-heatmap","sha":"d93ceaa99659f058cba495956ed04cb1b6514cb6","user":{"login":"thehyve","id":1502440,"avatar_url":"https://avatars.githubusercontent.com/u/1502440?v=3","gravatar_id":"","url":"https://api.github.com/users/thehyve","html_url":"https://github.com/thehyve","followers_url":"https://api.github.com/users/thehyve/followers","following_url":"https://api.github.com/users/thehyve/following{/other_user}","gists_url":"https://api.github.com/users/thehyve/gists{/gist_id}","starred_url":"https://api.github.com/users/thehyve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thehyve/subscriptions","organizations_url":"https://api.github.com/users/thehyve/orgs","repos_url":"https://api.github.com/users/thehyve/repos","events_url":"https://api.github.com/users/thehyve/events{/privacy}","received_events_url":"https://api.github.com/users/thehyve/received_events","type":"Organization","site_admin":false},"repo":{"id":43434009,"name":"heim-SmartR","full_name":"thehyve/heim-SmartR","owner":{"login":"thehyve","id":1502440,"avatar_url":"https://avatars.githubusercontent.com/u/1502440?v=3","gravatar_id":"","url":"https://api.github.com/users/thehyve","html_url":"https://github.com/thehyve","followers_url":"https://api.github.com/users/thehyve/followers","following_url":"https://api.github.com/users/thehyve/following{/other_user}","gists_url":"https://api.github.com/users/thehyve/gists{/gist_id}","starred_url":"https://api.github.com/users/thehyve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thehyve/subscriptions","organizations_url":"https://api.github.com/users/thehyve/orgs","repos_url":"https://api.github.com/users/thehyve/repos","events_url":"https://api.github.com/users/thehyve/events{/privacy}","received_events_url":"https://api.github.com/users/thehyve/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thehyve/heim-SmartR","description":"heim","fork":false,"url":"https://api.github.com/repos/thehyve/heim-SmartR","forks_url":"https://api.github.com/repos/thehyve/heim-SmartR/forks","keys_url":"https://api.github.com/repos/thehyve/heim-SmartR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thehyve/heim-SmartR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thehyve/heim-SmartR/teams","hooks_url":"https://api.github.com/repos/thehyve/heim-SmartR/hooks","issue_events_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/events{/number}","events_url":"https://api.github.com/repos/thehyve/heim-SmartR/events","assignees_url":"https://api.github.com/repos/thehyve/heim-SmartR/assignees{/user}","branches_url":"https://api.github.com/repos/thehyve/heim-SmartR/branches{/branch}","tags_url":"https://api.github.com/repos/thehyve/heim-SmartR/tags","blobs_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/refs{/sha}","trees_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thehyve/heim-SmartR/statuses/{sha}","languages_url":"https://api.github.com/repos/thehyve/heim-SmartR/languages","stargazers_url":"https://api.github.com/repos/thehyve/heim-SmartR/stargazers","contributors_url":"https://api.github.com/repos/thehyve/heim-SmartR/contributors","subscribers_url":"https://api.github.com/repos/thehyve/heim-SmartR/subscribers","subscription_url":"https://api.github.com/repos/thehyve/heim-SmartR/subscription","commits_url":"https://api.github.com/repos/thehyve/heim-SmartR/commits{/sha}","git_commits_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/commits{/sha}","comments_url":"https://api.github.com/repos/thehyve/heim-SmartR/comments{/number}","issue_comment_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/comments{/number}","contents_url":"https://api.github.com/repos/thehyve/heim-SmartR/contents/{+path}","compare_url":"https://api.github.com/repos/thehyve/heim-SmartR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thehyve/heim-SmartR/merges","archive_url":"https://api.github.com/repos/thehyve/heim-SmartR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thehyve/heim-SmartR/downloads","issues_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues{/number}","pulls_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls{/number}","milestones_url":"https://api.github.com/repos/thehyve/heim-SmartR/milestones{/number}","notifications_url":"https://api.github.com/repos/thehyve/heim-SmartR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thehyve/heim-SmartR/labels{/name}","releases_url":"https://api.github.com/repos/thehyve/heim-SmartR/releases{/id}","created_at":"2015-09-30T13:19:44Z","updated_at":"2015-10-16T10:25:47Z","pushed_at":"2015-11-17T15:32:48Z","git_url":"git://github.com/thehyve/heim-SmartR.git","ssh_url":"git@github.com:thehyve/heim-SmartR.git","clone_url":"https://github.com/thehyve/heim-SmartR.git","svn_url":"https://github.com/thehyve/heim-SmartR","homepage":"","size":2008,"stargazers_count":0,"watchers_count":0,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"dev"}},"base":{"label":"thehyve:dev","ref":"dev","sha":"dc11b30fa43d9645e5e9909a29695c54a6578941","user":{"login":"thehyve","id":1502440,"avatar_url":"https://avatars.githubusercontent.com/u/1502440?v=3","gravatar_id":"","url":"https://api.github.com/users/thehyve","html_url":"https://github.com/thehyve","followers_url":"https://api.github.com/users/thehyve/followers","following_url":"https://api.github.com/users/thehyve/following{/other_user}","gists_url":"https://api.github.com/users/thehyve/gists{/gist_id}","starred_url":"https://api.github.com/users/thehyve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thehyve/subscriptions","organizations_url":"https://api.github.com/users/thehyve/orgs","repos_url":"https://api.github.com/users/thehyve/repos","events_url":"https://api.github.com/users/thehyve/events{/privacy}","received_events_url":"https://api.github.com/users/thehyve/received_events","type":"Organization","site_admin":false},"repo":{"id":43434009,"name":"heim-SmartR","full_name":"thehyve/heim-SmartR","owner":{"login":"thehyve","id":1502440,"avatar_url":"https://avatars.githubusercontent.com/u/1502440?v=3","gravatar_id":"","url":"https://api.github.com/users/thehyve","html_url":"https://github.com/thehyve","followers_url":"https://api.github.com/users/thehyve/followers","following_url":"https://api.github.com/users/thehyve/following{/other_user}","gists_url":"https://api.github.com/users/thehyve/gists{/gist_id}","starred_url":"https://api.github.com/users/thehyve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thehyve/subscriptions","organizations_url":"https://api.github.com/users/thehyve/orgs","repos_url":"https://api.github.com/users/thehyve/repos","events_url":"https://api.github.com/users/thehyve/events{/privacy}","received_events_url":"https://api.github.com/users/thehyve/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thehyve/heim-SmartR","description":"heim","fork":false,"url":"https://api.github.com/repos/thehyve/heim-SmartR","forks_url":"https://api.github.com/repos/thehyve/heim-SmartR/forks","keys_url":"https://api.github.com/repos/thehyve/heim-SmartR/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thehyve/heim-SmartR/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thehyve/heim-SmartR/teams","hooks_url":"https://api.github.com/repos/thehyve/heim-SmartR/hooks","issue_events_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/events{/number}","events_url":"https://api.github.com/repos/thehyve/heim-SmartR/events","assignees_url":"https://api.github.com/repos/thehyve/heim-SmartR/assignees{/user}","branches_url":"https://api.github.com/repos/thehyve/heim-SmartR/branches{/branch}","tags_url":"https://api.github.com/repos/thehyve/heim-SmartR/tags","blobs_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/refs{/sha}","trees_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thehyve/heim-SmartR/statuses/{sha}","languages_url":"https://api.github.com/repos/thehyve/heim-SmartR/languages","stargazers_url":"https://api.github.com/repos/thehyve/heim-SmartR/stargazers","contributors_url":"https://api.github.com/repos/thehyve/heim-SmartR/contributors","subscribers_url":"https://api.github.com/repos/thehyve/heim-SmartR/subscribers","subscription_url":"https://api.github.com/repos/thehyve/heim-SmartR/subscription","commits_url":"https://api.github.com/repos/thehyve/heim-SmartR/commits{/sha}","git_commits_url":"https://api.github.com/repos/thehyve/heim-SmartR/git/commits{/sha}","comments_url":"https://api.github.com/repos/thehyve/heim-SmartR/comments{/number}","issue_comment_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues/comments{/number}","contents_url":"https://api.github.com/repos/thehyve/heim-SmartR/contents/{+path}","compare_url":"https://api.github.com/repos/thehyve/heim-SmartR/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thehyve/heim-SmartR/merges","archive_url":"https://api.github.com/repos/thehyve/heim-SmartR/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thehyve/heim-SmartR/downloads","issues_url":"https://api.github.com/repos/thehyve/heim-SmartR/issues{/number}","pulls_url":"https://api.github.com/repos/thehyve/heim-SmartR/pulls{/number}","milestones_url":"https://api.github.com/repos/thehyve/heim-SmartR/milestones{/number}","notifications_url":"https://api.github.com/repos/thehyve/heim-SmartR/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thehyve/heim-SmartR/labels{/name}","releases_url":"https://api.github.com/repos/thehyve/heim-SmartR/releases{/id}","created_at":"2015-09-30T13:19:44Z","updated_at":"2015-10-16T10:25:47Z","pushed_at":"2015-11-17T15:32:48Z","git_url":"git://github.com/thehyve/heim-SmartR.git","ssh_url":"git@github.com:thehyve/heim-SmartR.git","clone_url":"https://github.com/thehyve/heim-SmartR.git","svn_url":"https://github.com/thehyve/heim-SmartR","homepage":"","size":2008,"stargazers_count":0,"watchers_count":0,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25"},"html":{"href":"https://github.com/thehyve/heim-SmartR/pull/25"},"issue":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/issues/25"},"comments":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/thehyve/heim-SmartR/statuses/d93ceaa99659f058cba495956ed04cb1b6514cb6"}}}}