{"action":"created","issue":{"url":"https://api.github.com/repos/RGLab/openCyto/issues/187","repository_url":"https://api.github.com/repos/RGLab/openCyto","labels_url":"https://api.github.com/repos/RGLab/openCyto/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/RGLab/openCyto/issues/187/comments","events_url":"https://api.github.com/repos/RGLab/openCyto/issues/187/events","html_url":"https://github.com/RGLab/openCyto/issues/187","id":379625772,"node_id":"MDU6SXNzdWUzNzk2MjU3NzI=","number":187,"title":"Numeric groupBy not returning correct samples","user":{"login":"DillonHammill","id":28646736,"node_id":"MDQ6VXNlcjI4NjQ2NzM2","avatar_url":"https://avatars2.githubusercontent.com/u/28646736?v=4","gravatar_id":"","url":"https://api.github.com/users/DillonHammill","html_url":"https://github.com/DillonHammill","followers_url":"https://api.github.com/users/DillonHammill/followers","following_url":"https://api.github.com/users/DillonHammill/following{/other_user}","gists_url":"https://api.github.com/users/DillonHammill/gists{/gist_id}","starred_url":"https://api.github.com/users/DillonHammill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DillonHammill/subscriptions","organizations_url":"https://api.github.com/users/DillonHammill/orgs","repos_url":"https://api.github.com/users/DillonHammill/repos","events_url":"https://api.github.com/users/DillonHammill/events{/privacy}","received_events_url":"https://api.github.com/users/DillonHammill/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-11-12T05:23:49Z","updated_at":"2018-11-14T02:36:07Z","closed_at":null,"author_association":"NONE","body":"Hi @mikejiang,\r\n\r\nI have been trying to use the groupBy argument to split samples prior to gating. My understanding is that a numeric groupBy (n) spilts the data every n samples (i.e. if there are 6 samples and groupBy is set to 2, there should be 3 groups of 2 samples each group1 = files 1&2 group2 = files 3&4 group3 = files 5&6). This group assignment should be the same with every run of the gating pipeline, but this does not seem to be the case - the groups are changing each time. See trouble shooting below:\r\n\r\n```{r}\r\n# fs is a flowSet containing 6 flowFrames labelled Sample1 to Sample6\r\nfs \r\n\r\n#  add treatment info to pData - 3 groups A, B and C\r\npData(fs)$Treatment <- c(\"A\",\"A\",\"B\",\"C\",\"B\",\"C\")\r\n\r\n# add samples to GatingSet\r\ngs <- GatingSet(fs)\r\n\r\n# to report the grouping I wrote a preprocessing function which prints the sampleNames of the \r\n# groups (fs) to a global option called \"samples\"\r\nppTest <- function(fs, gs, gm, channels = NA, groupBy = NA, isCollapse = NA, ...){\r\noptions(\"samples\" = c(getOption(\"samples\"), list(sampleNames(fs))))\r\n}\r\nregisterPlugins(fun = ppTest, methodName = 'ppTest', dep=NA, \"preprocessing\")\r\n\r\n# Set \"samples\" option to empty list()\r\noptions(\"samples\" = list())\r\n\r\n# gate using add_pop API\r\nrow <- add_pop(gs,\r\n               alias = \"Test\",\r\n               pop = \"+\",\r\n               dims = \"FSC-A,\"SSC-A\",\r\n               parent = \"root\",\r\n               gating_method = \"flowClust\",\r\n               gating_args = \"K=2,target=c(50000,50000)\" ,\r\n               groupBy = 2,\r\n               collapseDataForGating = TRUE,\r\n               preprocessing_method = \"ppTest\")\r\n\r\n# printing \"samples\" should return a list of length 3 (1 element per group) with 2 sample names\r\n# each (e.g. Sample1 & Sample2, Sample3 & Sample4, Sample5 & Sample6) but this is not the case...\r\ngetOption(\"samples\")\r\n\r\n# Reset \"samples\" option\r\noption(\"samples\" = list())\r\n\r\n# Remove gate\r\nRm(\"Test\", gs)\r\n\r\n# Re-run add_pop() and print \"samples\"\r\ngetOption(\"samples\")\r\n\r\n# This output is different every time add_pop is run - grouping is not consistent...\r\n```\r\n\r\nGrouping using pData column names e.g. \"Treatment\" performs as expected with every run.\r\n\r\nI think removing sample() from this line will fix the problem:\r\nhttps://github.com/RGLab/openCyto/blob/26b062b09db7a68544cd29bd1799a06e8773435f/R/preprocessing-method.R#L67\r\n\r\nDillon\r\n"},"comment":{"url":"https://api.github.com/repos/RGLab/openCyto/issues/comments/438515988","html_url":"https://github.com/RGLab/openCyto/issues/187#issuecomment-438515988","issue_url":"https://api.github.com/repos/RGLab/openCyto/issues/187","id":438515988,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODUxNTk4OA==","user":{"login":"gfinak","id":1385593,"node_id":"MDQ6VXNlcjEzODU1OTM=","avatar_url":"https://avatars3.githubusercontent.com/u/1385593?v=4","gravatar_id":"","url":"https://api.github.com/users/gfinak","html_url":"https://github.com/gfinak","followers_url":"https://api.github.com/users/gfinak/followers","following_url":"https://api.github.com/users/gfinak/following{/other_user}","gists_url":"https://api.github.com/users/gfinak/gists{/gist_id}","starred_url":"https://api.github.com/users/gfinak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfinak/subscriptions","organizations_url":"https://api.github.com/users/gfinak/orgs","repos_url":"https://api.github.com/users/gfinak/repos","events_url":"https://api.github.com/users/gfinak/events{/privacy}","received_events_url":"https://api.github.com/users/gfinak/received_events","type":"User","site_admin":false},"created_at":"2018-11-14T02:36:07Z","updated_at":"2018-11-14T02:36:07Z","author_association":"MEMBER","body":"Okay, so I'm not sure where that behavior came from but I'll go with the intent of the inline comment. If it says split every nth sample then I agree we should change it to do that."}}
{"actor":{"display_login":"gfinak"}}