id
stringlengths
40
40
repo_name
stringlengths
5
110
path
stringlengths
2
233
content
stringlengths
0
1.03M
size
int32
0
60M
license
stringclasses
15 values
e0ae2022eab59371292c62d256dfaf3e49db1f71
dusenberrymw/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
asurve/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
eda7eba0e5bfc50e41f24b9e7ac55ba8950bcb8e
scheckley/shiny_mm
ui.R
#shinyapps::deployApp("/media/stephen/2AB4135CB4132A39/Users/schec/My Documents/coursera/data products/enzyme_kinetics/shiny_mm") library(shiny) #define the user interface shinyUI(fluidPage( #App title headerPanel("Michaelis Menten enzyme kinetics"), #Sidebar with slider controls sidebarPanel( numericInput("tmax", "simulation time:", 20, min=1, max=1000, step=NA), sliderInput("k1f","k1 forward:", min=0, max=10, value=1, step = 0.1), sliderInput("k1r","k1 reverse:", min=0, max=10, value=1, step = 0.1), sliderInput("k2", "k2:", min=0, max=10, value = 1, step = 0.1), sliderInput("S", "Initial [S]ubtrate conc.", min=0, max=100, value=100, step = 10), sliderInput("E", "Initial [E]nzyme conc.", min=0, max=100, value=10, step = 10) ), #Show the plot mainPanel( tabsetPanel( tabPanel("Model", img(src="mechanism.png"), plotOutput("kinetics_plot") ), tabPanel("Description", h3("Summary of an enzyme catalysed reaction"), img(src="enzyme_action.png"), br(), br(), h3("Introduction"), p("So, if you're not a biochemist you won't know what an enzyme is.", "For the uninitiated, chemical reactions happen by random chance and this can take a while to happen. Enzymes are biological entities which have", "evolved to help chemical reactions occur by increasing the chance of them happening. Enzymes facilitate all kinds of reactions while not being an", "active participant themselves (they change stuff but don't get changed themselves)."), p("Enzymes are of great interest to biologists because they can drive all kinds of reactions that wouldn't ordinarily occur (at least not within the lifetime of the researcher!).", "Biologists can adjust the properties of enzymes by modifying", "their attributes (like how efficiently they bind to reactants and how quickly they can convert them into product), usually to get them to drive faster reactions under", "particular conditions (like breaking down dirt on your clothes whilst being spun at 1200rpm at 30oC in your washing machine - not a naturally occuring environment!)"), p("This app simulates the process of an enzyme binding to a substrate and converting it to product. In a regular chemical reaction, this would be a 1:1 relationship and the", "concentration of product would increase linearly with concentration of substrate as one converts to the other. For enzyme driven reactions however, the enzyme is an intermediary and therefore", "the rate of the reaction is non-linear as it is governed by the performance of the enzyme, like the speed of a car is governed by the performance of the engine,", "but like an engine, an enzyme can be tuned. Welcome to the world of the enzyme kineticist!"), h3("App Instructions"), p("This app simulates the modifications a scientist can make to the attributes of an enzyme and reports the rate of product formation ([P]), substrate utilization [S]", "and information about the amount of free enzyle [E] complexed with substrate [ES]. You can also adjust the starting amount of enzyme and substrate", "The calculations are the same as those performed daily by enzyme kineticists the world over, and apps such as this are useful experimental tools."), strong("The parameters for the simulation are as follows:"), br(), img(src="mechanism.png"), p("k1 forward = forward rate for substrate [S] binding to enzyme[E], forming an enzyme-substrate complex [ES]."), p("k1 reverse = the reverse rate for substrate [S] unbinding from the enzyme-substrate complex [ES] before it gets chance to process it."), p("k2 = rate of conversion of the bound substrate [ES] to product [P] (releasing [E] to bind another free [S]). This is also known as the catalytic rate of the enzyme, or kcat."), p("S = the initial starting concentration of substrate, you can adjust this from 0 to lots."), p("E = the initial starting concentration of enzyme, you can adjust this from 0 to lots too. The maximum value matches the substrate because", "michaelis menten kinetics only hold for conditions where [S] >> [E], or you get all kinds of things happening with crowding of the enzyme.", "Inside cells, enzymes are usually present at much lower concentrations than their substrate and generally, michaelis-menten kinetics hold up as a reasonable approximation."), p("The length of the simulation time can also be set, which is useful for the plots. Simulation starts at time 0, so minimum time must be >0 (or the integrator will break; TARDIS not included!).", "1 to 100 are recommended simulation times."), h3("epilogue"), p("Enzyme kinetics is a huge field. For a much better description take a look at the", a("Wikipedia page",href="https://www.wikiwand.com/en/Enzyme_kinetics"), ", or a nice commemorative article on the", a("classic 1913 manuscript by Michaelis and Menten.", href="http://onlinelibrary.wiley.com/doi/10.1111/febs.12598/pdf")) ) ) ) ))
5,207
artistic-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
nakul02/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
deroneriksson/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
dusenberrymw/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
asurve/arvind-sysml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
niketanpansare/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
sandeep-n/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
dhutchis/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
akchinSTC/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
asurve/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
iyounus/incubator-systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
e0ae2022eab59371292c62d256dfaf3e49db1f71
nakul02/systemml
src/test/scripts/functions/vect/VectorizeLixColPos.R
#------------------------------------------------------------- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # #------------------------------------------------------------- args <- commandArgs(TRUE) options(digits=22) library("Matrix") A = as.matrix(readMM(paste(args[1], "A.mtx", sep=""))) R = A; R[7,3] = as.matrix(3); R[8,3] = as.matrix(4); writeMM(as(R, "CsparseMatrix"), paste(args[2], "R", sep=""));
1,159
apache-2.0
ef15db2a0b40b4f6d4a34a4d9b52bfbcffa23249
mathemage/h2o-3
h2o-r/tests/testdir_jira/runit_pubdev_2844.R
setwd(normalizePath(dirname(R.utils::commandArgs(asValues=TRUE)$"f"))) source("../../scripts/h2o-r-test-setup.R") test.pubdev_2844 <- function() { df1 <- iris h2o.no_progress() # as.h2o op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( hf1 <- as.h2o(df1, destination_frame = "pubdev2844.1") ) expect_true(is.h2o(hf1)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("maxLineLen", co)), label="as.h2o should produce verbose messages when data.table::fwrite verbose=TRUE is used") } else { expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is not used") } options(op) # as.h2o - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( hf2 <- as.h2o(df1, destination_frame = "pubdev2844.2") ) options(op) expect_true(is.h2o(hf2)) expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is forced disabled") # as.data.frame op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( df2 <- as.data.frame(hf1) ) expect_true(is.data.frame(df2)) if (use.package("data.table")) { expect_true(as.logical(length(co)), label="as.data.frame.H2OFrame should produce verbose messages when data.table::fread verbose=TRUE is used") } else { expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is not used") } options(op) # as.data.frame - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( df3 <- as.data.frame(hf2) ) options(op) expect_true(is.data.frame(df3)) expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is forced disabled") expect_equal(df1, df2, label="data.frame passed to h2o and back are equal") expect_equal(df1, df3, label="data.frame passed to h2o and back are equal also when data.table force disabled") # test "h2o.verbose" option to measure timing and also confirm fwrite/fread op <- options( "h2o.verbose"=TRUE, "h2o.use.data.table"=TRUE, "datatable.verbose"=FALSE ) co <- capture.output( hf3 <- as.h2o(df1, destination_frame = "pubdev2844.3") ) expect_true(is.h2o(hf3)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fwrite", co)), label="as.h2o should produce 'fwrite' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("write.csv", co)), label="as.h2o should produce 'write.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } # other way around co <- capture.output( df4 <- as.data.frame(hf3) ) expect_true(is.data.frame(df4)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fread", co)), label="as.data.frame.H2OFrame should produce 'fread' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("read.csv", co)), label="as.data.frame.H2OFrame should produce 'read.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } options(op) } doTest("PUBDEV-2844", test.pubdev_2844)
3,386
apache-2.0
ef15db2a0b40b4f6d4a34a4d9b52bfbcffa23249
spennihana/h2o-3
h2o-r/tests/testdir_jira/runit_pubdev_2844.R
setwd(normalizePath(dirname(R.utils::commandArgs(asValues=TRUE)$"f"))) source("../../scripts/h2o-r-test-setup.R") test.pubdev_2844 <- function() { df1 <- iris h2o.no_progress() # as.h2o op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( hf1 <- as.h2o(df1, destination_frame = "pubdev2844.1") ) expect_true(is.h2o(hf1)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("maxLineLen", co)), label="as.h2o should produce verbose messages when data.table::fwrite verbose=TRUE is used") } else { expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is not used") } options(op) # as.h2o - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( hf2 <- as.h2o(df1, destination_frame = "pubdev2844.2") ) options(op) expect_true(is.h2o(hf2)) expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is forced disabled") # as.data.frame op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( df2 <- as.data.frame(hf1) ) expect_true(is.data.frame(df2)) if (use.package("data.table")) { expect_true(as.logical(length(co)), label="as.data.frame.H2OFrame should produce verbose messages when data.table::fread verbose=TRUE is used") } else { expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is not used") } options(op) # as.data.frame - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( df3 <- as.data.frame(hf2) ) options(op) expect_true(is.data.frame(df3)) expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is forced disabled") expect_equal(df1, df2, label="data.frame passed to h2o and back are equal") expect_equal(df1, df3, label="data.frame passed to h2o and back are equal also when data.table force disabled") # test "h2o.verbose" option to measure timing and also confirm fwrite/fread op <- options( "h2o.verbose"=TRUE, "h2o.use.data.table"=TRUE, "datatable.verbose"=FALSE ) co <- capture.output( hf3 <- as.h2o(df1, destination_frame = "pubdev2844.3") ) expect_true(is.h2o(hf3)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fwrite", co)), label="as.h2o should produce 'fwrite' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("write.csv", co)), label="as.h2o should produce 'write.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } # other way around co <- capture.output( df4 <- as.data.frame(hf3) ) expect_true(is.data.frame(df4)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fread", co)), label="as.data.frame.H2OFrame should produce 'fread' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("read.csv", co)), label="as.data.frame.H2OFrame should produce 'read.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } options(op) } doTest("PUBDEV-2844", test.pubdev_2844)
3,386
apache-2.0
2f2849506f889b2ec6a2674c9223ed21d174ee1a
jakemkc/exposome_variability
src/Figure4_permute_spearman_r_p_value.R
## Jan 25 2017 ## Goal: Find p value for spearman r through permutation test ## Initialize the workspace rm(list=ls()) # clear workspace; # ls() # list objects in the workspace cat("\014") # same as ctrl-L # load load("results/corr_chems_heatmap__resid_lipid_creat_adj_v2.Rdata") # ******** ----- # A. Perm. p for spearman R ------------------------------------------------------------- ######################################################### # ## \\ A1. within females ---- ######################################################### # ## now my code ## nc <- ncol(resid_impute_f)-1 pertime <- 1000 # variable arrayref <- array(0, dim = c(nc, nc, pertime)) colnames(arrayref) <- colnames(resid_impute_f)[-1] rownames(arrayref) <- colnames(resid_impute_f)[-1] corr_per_imp <- list() # On the lower half matrix for(h in 1:10){ for(i in 1:(nc-1)) { # col, i for(j in seq(i+1, nc)){ # row, j for (k in 1:pertime){ tmpfr <- subset(resid_impute_f, X_Imputation_ == h)[2:ncol(resid_impute_f)] y <- tmpfr[, i] x <- tmpfr[, j] x2 <- sample(x, replace = F) rs <- cor(x2, y, method = "spearman") arrayref[j, i, k] <- rs corr_per_imp[[h]] <- arrayref } } } } ## combine array in List to a single array arrayperm <- array(unlist(corr_per_imp), dim = c(nc, nc, pertime*h)) # rubin spearman r rubin_r <- corrubinf p_perm_spear_r <- matrix(NA, nrow = nc, ncol = nc) colnames(p_perm_spear_r) <- colnames(resid_impute_f)[-1] rownames(p_perm_spear_r) <- colnames(resid_impute_f)[-1] # loop to get permuted p value for(i in 1:(nc-1)){ # col, i for(j in seq(i+1, nc)){ # row, j rub_r <- rubin_r[j, i] # mind it's j i and i j perm_r <- arrayperm[j, i, ] p_spearman_r <- mean(append(abs(perm_r) > abs(rub_r), 1)) p_perm_spear_r[j, i] <- p_spearman_r } } p_perm_spear_f <- p_perm_spear_r save(file = file.path("results", "perm_p_value_f_resid_lipid_creat_adj_v2.Rdata"), life, impute_f, impute_m, resid_impute_f, resid_impute_m, p_perm_spear_f, corrubinf, corrubinm, corrubinmf) ######################################################### # ## \\ A2. within males ---- ######################################################### # ## now my code ## nc <- ncol(resid_impute_m)-1 pertime <- 1000 # variable arrayref <- array(0, dim = c(nc, nc, pertime)) colnames(arrayref) <- colnames(resid_impute_m)[-1] rownames(arrayref) <- colnames(resid_impute_m)[-1] corr_per_imp <- list() # On the lower half matrix for(h in 1:10){ for(i in 1:(nc-1)) { # col, i for(j in seq(i+1, nc)){ # row, j for (k in 1:pertime){ tmpfr <- subset(resid_impute_m, X_Imputation_ == h)[2:ncol(resid_impute_m)] y <- tmpfr[, i] x <- tmpfr[, j] x2 <- sample(x, replace = F) rs <- cor(x2, y, method = "spearman") arrayref[j, i, k] <- rs corr_per_imp[[h]] <- arrayref } } } } ## combine array in List to a single array arrayperm <- array(unlist(corr_per_imp), dim = c(nc, nc, pertime*h)) # rubin spearman r rubin_r <- corrubinm p_perm_spear_r <- matrix(NA, nrow = nc, ncol = nc) colnames(p_perm_spear_r) <- colnames(resid_impute_m)[-1] rownames(p_perm_spear_r) <- colnames(resid_impute_m)[-1] # loop to get permuted p value for(i in 1:(nc-1)){ # col, i for(j in seq(i+1, nc)){ # row, j rub_r <- rubin_r[j, i] # mind it's j i and i j perm_r <- arrayperm[j, i, ] p_spearman_r <- mean(append(abs(perm_r) > abs(rub_r), 1)) p_perm_spear_r[j, i] <- p_spearman_r } } p_perm_spear_m <- p_perm_spear_r save(file = file.path("results", "perm_p_value_m_resid_lipid_creat_adj_v2.Rdata"), life, impute_f, impute_m, resid_impute_m, resid_impute_m, p_perm_spear_m, corrubinf, corrubinm, corrubinmf) ######################################################### # ## \\ A3. within couples ---- ######################################################### # ## now my code ## nc <- ncol(resid_impute_f)-1 pertime <- 1000 # variable arrayref <- array(0, dim = c(nc, nc, pertime)) colnames(arrayref) <- colnames(resid_impute_f)[-1] rownames(arrayref) <- colnames(resid_impute_m)[-1] corr_per_imp <- list() # On the whole matrix for(h in 1:10){ for(i in 1:nc) { # col, i for(j in 1:nc){ # row, j for (k in 1:pertime){ tmpfr1 <- subset(resid_impute_f, X_Imputation_ == h)[2:ncol(resid_impute_f)] tmpfr2 <- subset(resid_impute_m, X_Imputation_ == h)[2:ncol(resid_impute_m)] y <- tmpfr1[, i] x <- tmpfr2[, j] x2 <- sample(x, replace = F) rs <- cor(x2, y, method = "spearman") arrayref[j, i, k] <- rs corr_per_imp[[h]] <- arrayref } } } } ## combine array in List to a single array arrayperm <- array(unlist(corr_per_imp), dim = c(nc, nc, pertime*h)) # rubin spearman r (rowname is males for couples, same for corr_per_imp. A match) rubin_r <- corrubinmf p_perm_spear_r <- matrix(NA, nrow = nc, ncol = nc) colnames(p_perm_spear_r) <- colnames(resid_impute_f)[-1] rownames(p_perm_spear_r) <- colnames(resid_impute_m)[-1] # loop to get permuted p value for(i in 1:nc){ # col, i for(j in 1:nc){ # row, j rub_r <- rubin_r[j, i] # mind it's j i and i j perm_r <- arrayperm[j, i, ] p_spearman_r <- mean(append(abs(perm_r) > abs(rub_r), 1)) p_perm_spear_r[j, i] <- p_spearman_r } } p_perm_spear_mf <- p_perm_spear_r save(file = file.path("results", "perm_p_value_mf_resid_lipid_creat_adj_v2.Rdata"), life, impute_f, impute_m, resid_impute_f, resid_impute_m, p_perm_spear_mf, corrubinf, corrubinm, corrubinmf)
6,071
mit
e4906d4abc0e5f098a813c994fc26d264fea9514
MatthiasHinz/containerit
tests/testthat/test_find_systemrequirements.R
# Copyright 2017 Opening Reproducible Research (http://o2r.info) context("find system requrirements") test_that("system requirements for CRAN packages can be determinded", { #test may have to be adjusted if system requriements change deps <- .find_system_dependencies("sp", method = "sysreq-package", platform = .debian_platform, soft = TRUE) deps_expected <- c("libproj-dev", "libgdal-dev", "gdal-bin", "libgeos-dev") expect_true(all(deps %in% deps_expected)) expect_true(all(deps_expected %in% deps)) deps <- .find_system_dependencies("sp", method = "sysreq-package", platform = .debian_platform, soft = FALSE) expect_equal(deps, character(0)) #no direct dependencies deps <- .find_system_dependencies("rgdal", method = "sysreq-package", platform = .debian_platform, soft = TRUE) deps_expected <- c("libgdal-dev", "gdal-bin","libproj-dev") expect_true(all(deps %in% deps_expected)) expect_true(all(deps_expected %in% deps)) deps <- .find_system_dependencies("rgdal", method = "sysreq-api", platform = .debian_platform) deps_expected <- c("libgdal-dev", "gdal-bin","libproj-dev") expect_true(all(deps %in% deps_expected)) expect_true(all(deps_expected %in% deps)) })
1,216
gpl-3.0
ef15db2a0b40b4f6d4a34a4d9b52bfbcffa23249
h2oai/h2o-dev
h2o-r/tests/testdir_jira/runit_pubdev_2844.R
setwd(normalizePath(dirname(R.utils::commandArgs(asValues=TRUE)$"f"))) source("../../scripts/h2o-r-test-setup.R") test.pubdev_2844 <- function() { df1 <- iris h2o.no_progress() # as.h2o op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( hf1 <- as.h2o(df1, destination_frame = "pubdev2844.1") ) expect_true(is.h2o(hf1)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("maxLineLen", co)), label="as.h2o should produce verbose messages when data.table::fwrite verbose=TRUE is used") } else { expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is not used") } options(op) # as.h2o - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( hf2 <- as.h2o(df1, destination_frame = "pubdev2844.2") ) options(op) expect_true(is.h2o(hf2)) expect_true(!length(co), label="as.h2o should not produce verbose messages when data.table::fwrite is forced disabled") # as.data.frame op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=TRUE) co <- capture.output( df2 <- as.data.frame(hf1) ) expect_true(is.data.frame(df2)) if (use.package("data.table")) { expect_true(as.logical(length(co)), label="as.data.frame.H2OFrame should produce verbose messages when data.table::fread verbose=TRUE is used") } else { expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is not used") } options(op) # as.data.frame - data.table off op <- options("datatable.verbose"=TRUE, "h2o.use.data.table"=FALSE) co <- capture.output( df3 <- as.data.frame(hf2) ) options(op) expect_true(is.data.frame(df3)) expect_true(!length(co), label="as.data.frame.H2OFrame should not produce verbose messages when data.table::fread is forced disabled") expect_equal(df1, df2, label="data.frame passed to h2o and back are equal") expect_equal(df1, df3, label="data.frame passed to h2o and back are equal also when data.table force disabled") # test "h2o.verbose" option to measure timing and also confirm fwrite/fread op <- options( "h2o.verbose"=TRUE, "h2o.use.data.table"=TRUE, "datatable.verbose"=FALSE ) co <- capture.output( hf3 <- as.h2o(df1, destination_frame = "pubdev2844.3") ) expect_true(is.h2o(hf3)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fwrite", co)), label="as.h2o should produce 'fwrite' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("write.csv", co)), label="as.h2o should produce 'write.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } # other way around co <- capture.output( df4 <- as.data.frame(hf3) ) expect_true(is.data.frame(df4)) if (use.package("data.table")) { expect_true(length(co) && sum(grepl("fread", co)), label="as.data.frame.H2OFrame should produce 'fread' in timing message when h2o.verbose=TRUE and data.table used.") } else { expect_true(length(co) && sum(grepl("read.csv", co)), label="as.data.frame.H2OFrame should produce 'read.csv' in timing message when h2o.verbose=TRUE and data.table not used.") } options(op) } doTest("PUBDEV-2844", test.pubdev_2844)
3,386
apache-2.0
1e041f47b8022b8f7913118139501a9d88e719eb
Simontuk/hello_world
00N_LoadData.R
library(minfi) library(data.table) library(MethylAid) library(parallel) library(data.table) args <- commandArgs(TRUE) dataset <- args[1] # Define "Local Dataset" #dataset <- "ACC" ## adapt path to dataset main.dir <- '/icgc/dkfzlsdf/analysis/B080/steiger' data.dir <- file.path(main.dir,'data',dataset) out.dir <- file.path(data.dir,'output') r.dir <- file.path(main.dir,"scripts") # Automatic File Search in all directories meth.name <- paste(dataset,'.methylation__humanmethylation450__jhu_usc_edu__Level_3__within_bioassay_data_set_function__data.data.txt',sep="") rnaseq.name <- paste(dataset,'.uncv2.mRNAseq_RSEM_normalized_log2_PARADIGM.txt',sep="") meth.dir <- list.files(data.dir,pattern = meth.name,recursive=T) rnaseq.dir <- list.files(data.dir,pattern = rnaseq.name,recursive=T) dir.create(out.dir) dir.create(paste(out.dir,"/RData",sep="")) mRNAdata <- file.path(data.dir,rnaseq.dir) data450k <- file.path(data.dir,meth.dir) # Source the Function files source(file.path(r.dir,"00_GeneralFunctions.R")) source(file.path(r.dir,'00_NewFunctions.R')) X.entity <- fread(mRNAdata) M.entity <- readTCGA(data450k) # Changing Column Names / Sample Names of Methylation Data Set M.id <- colnames(M.entity) M.id <- sapply(lapply(strsplit(M.id,"\\-"),'[',1:4),function(x) {y <- paste0(x,collapse="."); gsub("[A-Z]$","",y)}) colnames(M.entity) <- M.id # Changing Column Names / Sample Names of Expression Data Set X.entity$gene <- sapply(strsplit(X.entity$gene,"\\|"),'[[',2) setkey(X.entity,gene) #X.entity <- X.entity[,!"gene",with = F] X.id <- colnames(X.entity[,.SD,.SDcols=-key(X.entity)]) X.id <- sapply(lapply(strsplit(X.id,"\\-"),'[',1:4),function(x) {y <- paste0(x,collapse="."); gsub("[A-Z]$","",y)}) # Keep in Mind: data.table object setnames(X.entity,colnames(X.entity[,.SD,.SDcols=-key(X.entity)]),new = X.id) # Gene-id extract i.na <- which(apply(X.entity[,.SD,.SDcols=-key(X.entity)],1,function(x) {sum(!is.na(x))==0})) X.entity <- X.entity[-i.na,] #dim(X.entity) i.na <- which(apply(getBeta(M.entity),1,function(x) {sum(!is.na(x))==0})) M.entity <- M.entity[-i.na,] #dim(M.entity) common <- intersect(X.id,M.id) i.m <- match(common,M.id) i.x <- match(common,X.id) X.entity <- X.entity[,c(1,i.x+1),with=F] M.entity <- M.entity[,i.m] i.cg <- grep("cg",rownames(M.entity)) M.entity <- M.entity[i.cg,] message('Computing median and sd ....') STAT.entity <- data.frame(sd=apply(getBeta(M.entity),1,sd,na.rm=T), iqr=apply(getBeta(M.entity),1,IQR,na.rm=T), med=apply(getBeta(M.entity),1,median,na.rm=T), mean=apply(getBeta(M.entity),1,mean,na.rm=T)) STAT.entity <- STAT.entity[order(STAT.entity$iqr,decreasing=T),] #### # Choose the 100k most variable #### #selected.cg <- rownames(STAT.entity)[1:100000] #M.entity <- M.entity[selected.cg,] #### ### #Saving the Data ### save('X.entity', 'M.entity', 'STAT.entity', file=file.path(out.dir,paste('RData/',dataset,'.load.RData',sep="")), compress='bzip2') ### rm() gc() ###
3,055
gpl-2.0
6536b722766389b39682156444157368e881bf80
wotuzu17/tronador
R_packages/quantify/pkg/R/qDSMAStatus.R
# function calculates quantile status of first derivative of SMA of # a rollingwindow # currently, only 3 levels are supported. qDSMAStatus <- function (TS, n, rollingwindow) { SMA <- SMA(Cl(TS), n=n) FD_SMA <- diff(SMA) FD_SMA_Q <- cbind( rollapply(FD_SMA, rollingwindow, quantile, probs=.25, na.rm=TRUE), rollapply(FD_SMA, rollingwindow, quantile, probs=.75, na.rm=TRUE) ) FD_SMA_S <- rollapply(FD_SMA, 1, function(x) { as.numeric(x > FD_SMA_Q[,1]) + as.numeric(x > FD_SMA_Q[,2])}) colnames(FD_SMA_S) <- c(paste0("FSMA", n)) return(FD_SMA_S) }
576
mit
2c9951079bc32f7c909ecafc809f7f0af826fbe2
vnminin/SISMID_MCMC_I
2019/code/diagnostics.R
## This script illustrates some diagnostic tools available in package coda ## Author: Vladimir N. Minin ## last update: 07/14/19 ## first we need to load coda and mcmcse packages (you need to install them first) library(coda) library(mcmcse) ## now let's load our M-H and Gibbs sampler examples source("https://raw.githubusercontent.com/vnminin/SISMID_MCMC_I/master/2016/code/chainGibbs.R") dev.off() ## run one M-H example chain gibbs.chain1 = chainGibbs(5000, 1,1) ## convert the output into coda format coda.gibbs.chain = mcmc(cbind(gibbs.chain1$q[101:5000],gibbs.chain1$n111[101:5000])) summary(coda.gibbs.chain) ## we can also compute Monte Carlo error for the quantiles mcse.q.mat(coda.gibbs.chain, 0.025) mcse.q.mat(coda.gibbs.chain, 0.975) ## plot traceplots and (hopefully) posterior densities plot(coda.gibbs.chain) ## look at what coda can do help(package=coda) ## look at the menu options ##codamenu() ## all commands are availabe outside of the menu ## plot autocorrelations plots autocorr.plot(coda.gibbs.chain) ## calculate effective sample size effectiveSize(coda.gibbs.chain) ## Run 50 chains with overdispersed starting values coda.gibbs.chains = list() for (i in 1:50){ gibbs.chain = chainGibbsUserStart(1000,1,1,sample(0:275,size=1)) coda.gibbs.chains[[i]] = mcmc(cbind(gibbs.chain$q,gibbs.chain$n111)) } coda.gibbs.list = mcmc.list(coda.gibbs.chains) plot(coda.gibbs.list) ## compute and plot Gelman-Rubin potential reduction factor gelman.diag(coda.gibbs.list) gelman.plot(coda.gibbs.list) ## Exersise: perform diagnostics for SIR data augmentatkon MCMC source("https://raw.githubusercontent.com/vnminin/SISMID_MCMC_I/master/2019/code/SIRaugmentation.R") coda_sir_chain = mcmc(mcmc.sample) summary(coda_sir_chain) mcse.q.mat(coda_sir_chain, 0.025) mcse.q.mat(coda_sir_chain, 0.975) plot(coda_sir_chain) ## plot autocorrelations plots autocorr.plot(coda_sir_chain) ## calculate effective sample size effectiveSize(coda_sir_chain) coda_sir_chains = list() for (i in 1:50){ sir_chain = sampleSIR_set_init(remtimes,M=120,600, rexp(1), rexp(1)) coda_sir_chains[[i]] = mcmc(sir_chain) } coda_sir_list = mcmc.list(coda_sir_chains) plot(coda_sir_list) ## compute and plot Gelman-Rubin potential reduction factor gelman.diag(coda_sir_list) gelman.plot(coda_sir_list)
2,325
gpl-2.0
7c544f8d89f1e638eec6ae01fed36f47badaa00e
maddin79/darch
R/rbmUpdate.R
# Copyright (C) 2013-2016 Martin Drees # # This file is part of darch. # # darch is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # darch is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with darch. If not, see <http://www.gnu.org/licenses/>. #' Function for updating the weights and biases of an \code{RBM} #' #' This function updates the weights and biases for an \code{\linkS4class{RBM}} #' network. It is saved in the attribute \code{updateFunction} of the #' \code{RBM} object and called from the training function #' \code{\link{trainRBM}}. #' #' @param rbm A instance of the class \code{\linkS4class{RBM}}. #' @param matMult Matrix multiplication function. #' @param ... Additional arguments. #' @return The updated \code{\linkS4class{RBM}}. #' @export #' @seealso \code{\linkS4class{RBM}} #' @keywords internal rbmUpdate <- function(rbm, matMult = getParameter(".matMult", net = rbm)) { # get parameters momentum <- getMomentum(rbm) weightsInc <- rbm@weightsInc weights <- rbm@weights visibleBiasInc <- rbm@visibleBiasesInc visibleBiases <- rbm@visibleBiases hiddenBiasInc <- rbm@hiddenBiasesInc hiddenBiases <- rbm@hiddenBiases data <- rbm@posPhaseData[[1]] posHiddenProbs <- rbm@posPhaseData[[2]][[1]] negativeData <- rbm@visibleUnitStates[[1]] negHiddenProbs <- rbm@hiddenUnitStates[[1]] learnRate <- (getParameter(".rbm.learnRate", net = rbm) * getParameter(".rbm.learnRateScale", net = rbm) ^ rbm@epochs * (1 - momentum)) weightDecay <- getParameter(".rbm.weightDecay", net = rbm) batchSize <- getParameter(".rbm.batchSize", net = rbm) # positive phase posProducts <- matMult(t(data), posHiddenProbs) posHiddienAct <- colSums(posHiddenProbs) posVisibleAct <- colSums(data) # negative phase negProducts <- matMult(t(negativeData), negHiddenProbs) negHiddienAct <- colSums(negHiddenProbs) negVisibleAct <- colSums(negativeData) # update weightsInc <- momentum * weightsInc + learnRate * (((posProducts - negProducts) / batchSize) - weightDecay * weights) visibleBiasInc <- momentum * visibleBiasInc + (learnRate / batchSize) * (posVisibleAct - negVisibleAct - visibleBiases * weightDecay) hiddenBiasInc <- momentum * hiddenBiasInc + (learnRate / batchSize) * (posHiddienAct - negHiddienAct - hiddenBiases * weightDecay) weights <- weights + weightsInc if (getParameter(".normalizeWeights", net = rbm)) { normalizeWeightsCpp(weights, getParameter(".normalizeWeightsBound", net = rbm)) } rbm@weights <- weights rbm@visibleBiases <- visibleBiases + visibleBiasInc rbm@hiddenBiases <- hiddenBiases + hiddenBiasInc rbm@weightsInc <- weightsInc rbm@visibleBiasesInc <- visibleBiasInc rbm@hiddenBiasesInc <- hiddenBiasInc rbm }
3,208
gpl-3.0
7c544f8d89f1e638eec6ae01fed36f47badaa00e
cran/darch
R/rbmUpdate.R
# Copyright (C) 2013-2016 Martin Drees # # This file is part of darch. # # darch is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # darch is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with darch. If not, see <http://www.gnu.org/licenses/>. #' Function for updating the weights and biases of an \code{RBM} #' #' This function updates the weights and biases for an \code{\linkS4class{RBM}} #' network. It is saved in the attribute \code{updateFunction} of the #' \code{RBM} object and called from the training function #' \code{\link{trainRBM}}. #' #' @param rbm A instance of the class \code{\linkS4class{RBM}}. #' @param matMult Matrix multiplication function. #' @param ... Additional arguments. #' @return The updated \code{\linkS4class{RBM}}. #' @export #' @seealso \code{\linkS4class{RBM}} #' @keywords internal rbmUpdate <- function(rbm, matMult = getParameter(".matMult", net = rbm)) { # get parameters momentum <- getMomentum(rbm) weightsInc <- rbm@weightsInc weights <- rbm@weights visibleBiasInc <- rbm@visibleBiasesInc visibleBiases <- rbm@visibleBiases hiddenBiasInc <- rbm@hiddenBiasesInc hiddenBiases <- rbm@hiddenBiases data <- rbm@posPhaseData[[1]] posHiddenProbs <- rbm@posPhaseData[[2]][[1]] negativeData <- rbm@visibleUnitStates[[1]] negHiddenProbs <- rbm@hiddenUnitStates[[1]] learnRate <- (getParameter(".rbm.learnRate", net = rbm) * getParameter(".rbm.learnRateScale", net = rbm) ^ rbm@epochs * (1 - momentum)) weightDecay <- getParameter(".rbm.weightDecay", net = rbm) batchSize <- getParameter(".rbm.batchSize", net = rbm) # positive phase posProducts <- matMult(t(data), posHiddenProbs) posHiddienAct <- colSums(posHiddenProbs) posVisibleAct <- colSums(data) # negative phase negProducts <- matMult(t(negativeData), negHiddenProbs) negHiddienAct <- colSums(negHiddenProbs) negVisibleAct <- colSums(negativeData) # update weightsInc <- momentum * weightsInc + learnRate * (((posProducts - negProducts) / batchSize) - weightDecay * weights) visibleBiasInc <- momentum * visibleBiasInc + (learnRate / batchSize) * (posVisibleAct - negVisibleAct - visibleBiases * weightDecay) hiddenBiasInc <- momentum * hiddenBiasInc + (learnRate / batchSize) * (posHiddienAct - negHiddienAct - hiddenBiases * weightDecay) weights <- weights + weightsInc if (getParameter(".normalizeWeights", net = rbm)) { normalizeWeightsCpp(weights, getParameter(".normalizeWeightsBound", net = rbm)) } rbm@weights <- weights rbm@visibleBiases <- visibleBiases + visibleBiasInc rbm@hiddenBiases <- hiddenBiases + hiddenBiasInc rbm@weightsInc <- weightsInc rbm@visibleBiasesInc <- visibleBiasInc rbm@hiddenBiasesInc <- hiddenBiasInc rbm }
3,208
gpl-3.0
998c92698fcefd8d888c63428e5886e08f0df5aa
tarakc02/rcrunchbase
tests/testthat/test-expand-section.R
context("expand-section") test_that("sections can be expanded regardless of where they came from", { fb_node <- crunchbase_parse(crunchbase_GET("organizations/facebook")) fb_nodes <- crunchbase_get_details("organizations/facebook") expect_that(crunchbase_expand_section(fb_node, "current_team"), is_identical_to(crunchbase_expand_section(fb_nodes, "current_team"))) }) test_that("can expand sections from multiple nodes", { nodes <- crunchbase_get_details(c("organizations/facebook", "organizations/twitter")) expect_is(crunchbase_expand_section(nodes, c("current_team", "past_team")), "data.frame") })
681
mit
998c92698fcefd8d888c63428e5886e08f0df5aa
ofirsh/rcrunchbase
tests/testthat/test-expand-section.R
context("expand-section") test_that("sections can be expanded regardless of where they came from", { fb_node <- crunchbase_parse(crunchbase_GET("organizations/facebook")) fb_nodes <- crunchbase_get_details("organizations/facebook") expect_that(crunchbase_expand_section(fb_node, "current_team"), is_identical_to(crunchbase_expand_section(fb_nodes, "current_team"))) }) test_that("can expand sections from multiple nodes", { nodes <- crunchbase_get_details(c("organizations/facebook", "organizations/twitter")) expect_is(crunchbase_expand_section(nodes, c("current_team", "past_team")), "data.frame") })
681
mit
fb938a8984327cee4f59e41c64bcca5f71dac8fb
cran/Zelig
R/model-negbinom.R
#' Negative Binomial Regression for Event Count Dependent Variables #'@param formula a symbolic representation of the model to be #' estimated, in the form \code{y ~ x1 + x2}, where \code{y} is the #' dependent variable and \code{x1} and \code{x2} are the explanatory #' variables, and \code{y}, \code{x1}, and \code{x2} are contained in the #' same dataset. (You may include more than two explanatory variables, #' of course.) The \code{+} symbol means ``inclusion'' not #' ``addition.'' You may also include interaction terms and main #' effects in the form \code{x1*x2} without computing them in prior #' steps; \code{I(x1*x2)} to include only the interaction term and #' exclude the main effects; and quadratic terms in the form #' \code{I(x1^2)}. #' @param model the name of a statistical model to estimate. #' For a list of other supported models and their documentation see: #' \url{http://docs.zeligproject.org/articles/}. #' @param data the name of a data frame containing the variables #' referenced in the formula or a list of multiply imputed data frames #' each having the same variable names and row numbers (created by #' \code{Amelia} or \code{\link{to_zelig_mi}}). #' @param ... additional arguments passed to \code{zelig}, #' relevant for the model to be estimated. #' @param by a factor variable contained in \code{data}. If supplied, #' \code{zelig} will subset #' the data frame based on the levels in the \code{by} variable, and #' estimate a model for each subset. This can save a considerable amount of #' effort. You may also use \code{by} to run models using MatchIt #' subclasses. #' @param cite If is set to 'TRUE' (default), the model citation will be printed #' to the console. #' #' @details #' Additional parameters avaialable to this model include: #' \itemize{ #' \item \code{weights}: vector of weight values or a name of a variable in the dataset #' by which to weight the model. For more information see: #' \url{http://docs.zeligproject.org/articles/weights.html}. #' \item \code{bootstrap}: logical or numeric. If \code{FALSE} don't use bootstraps to #' robustly estimate uncertainty around model parameters due to sampling error. #' If an integer is supplied, the number of boostraps to run. #' For more information see: #' \url{http://docs.zeligproject.org/articles/bootstraps.html}. #' } #' @return Depending on the class of model selected, \code{zelig} will return #' an object with elements including \code{coefficients}, \code{residuals}, #' and \code{formula} which may be summarized using #' \code{summary(z.out)} or individually extracted using, for example, #' \code{coef(z.out)}. See #' \url{http://docs.zeligproject.org/articles/getters.html} for a list of #' functions to extract model components. You can also extract whole fitted #' model objects using \code{\link{from_zelig_model}}. #' #'@examples #' library(Zelig) #' data(sanction) #' z.out <- zelig(num ~ target + coop, model = "negbin", data = sanction) #' summary(z.out) #' #' @seealso Vignette: \url{http://docs.zeligproject.org/articles/zelig_negbin.html} #' @import methods #' @export Zelig-negbin #' @exportClass Zelig-negbin #' #' @include model-zelig.R znegbin <- setRefClass("Zelig-negbin", contains = "Zelig", field = list(simalpha = "list" # ancillary parameters )) znegbin$methods( initialize = function() { callSuper() .self$fn <- quote(MASS::glm.nb) .self$name <- "negbin" .self$authors <- "Kosuke Imai, Gary King, Olivia Lau" .self$packageauthors <- "William N. Venables, and Brian D. Ripley" .self$year <- 2008 .self$category <- "count" .self$description <- "Negative Binomial Regression for Event Count Dependent Variables" # JSON .self$outcome <- "discrete" .self$wrapper <- "negbin" .self$acceptweights <- TRUE } ) znegbin$methods( zelig = function(formula, data, ..., weights=NULL, by = NULL, bootstrap = FALSE) { .self$zelig.call <- match.call(expand.dots = TRUE) .self$model.call <- .self$zelig.call callSuper(formula=formula, data=data, ..., weights=weights, by = by, bootstrap = bootstrap) rse <- lapply(.self$zelig.out$z.out, (function(x) vcovHC(x, type = "HC0"))) .self$test.statistics<- list(robust.se = rse) } ) znegbin$methods( param = function(z.out, method="mvn") { simalpha.local <- z.out$theta if(identical(method,"mvn")){ simparam.local <- mvrnorm(n = .self$num, mu = coef(z.out), Sigma = vcov(z.out)) simparam.local <- list(simparam = simparam.local, simalpha = simalpha.local) return(simparam.local) } else if(identical(method,"point")){ return(list(simparam = t(as.matrix(coef(z.out))), simalpha = simalpha.local)) } } ) znegbin$methods( qi = function(simparam, mm) { coeff <- simparam$simparam alpha <- simparam$simalpha inverse <- family(.self$zelig.out$z.out[[1]])$linkinv eta <- coeff %*% t(mm) theta <- matrix(inverse(eta), nrow=nrow(coeff)) ev <- theta pv <- matrix(NA, nrow=nrow(theta), ncol=ncol(theta)) # for (i in 1:ncol(ev)) pv[, i] <- rnegbin(nrow(ev), mu = ev[i, ], theta = alpha[i]) return(list(ev = ev, pv = pv)) } ) znegbin$methods( mcfun = function(x, b0=0, b1=1, ..., sim=TRUE){ mu <- exp(b0 + b1 * x) if(sim){ y <- rnbinom(n=length(x), 1, mu=mu) return(y) }else{ return(mu) } } )
5,539
gpl-2.0
090d3b50284625678ba48692154d8e7c87f3033e
krlmlr/cxxr
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
0efdc31319de0a611523a1abb7c93845ee12f6b2
rodrigoesborges/conjuntuRa
Nacional-Brasil/03_mercado_de_trabalho-RAIS-CAGED.R
require(microdadosBrasil) require(data.table) require(readr) require(readxl) require(dplyr) require(plotly) anos <- seq(1994,2017,1) ufs <- c("AC","AL","AM","AP","BA","CE", "DF", "ES", "GO", "MA","MG","MS","MT","PA","PB","PE","PI","PR","RN","RJ","RO","RR","RS","SC","SE","SOP","TO") nomescols <- c("ano","uf","divisao","percentual","vinculos") proxysuper <- data.frame(matrix(ncol = 5, nrow = 0)) colnames(proxysuper) <-nomescols for (ano in anos) { for (uf in ufs) { rais <- read_RAIS("vinculos", i = ano, UF = uf, root_path = "~/RLocalData/RAIS", vars_subset = c("CNAE 95 Classe","Faixa Remun M\xe9dia (SM)")) raisocupas <- rais raisocupas$"Faixa Remun M\xe9dia (SM)" <- as.numeric(raisocupas$"Faixa Remun M\xe9dia (SM)") seden <- nrow(raisocupas) if (nrow(raisocupas) == 0) { seden = 1 } raissuper <- raisocupas[ raisocupas$"Faixa Remun M\xe9dia (SM)" <= 3] senum <- nrow(raissuper) superexp <- senum/seden novovalor <- data.frame(ano, uf, divisao,superexp,nrow(raisocupas)) names(novovalor) <- nomescols proxysuper <- rbind(proxysuper,novovalor) write.csv2(proxysuper,paste0("data/serie2sm",anos[1],"-",ano,".csv")) gc() } } write.csv2(proxysuper,paste0("data/serie2sm",anos[1],"-",ano,".csv")) #DESAGREGAR POR SETORES #Específico para projeto de Camilla #CNAE95 <-read_xlsx("~/RLocalData/CNAE 95 _div.xlsx", col_names = TRUE) #divisões específicas solicitadas por seu projeto - levaram a incluir um loop adicional # e coluna a mais nos resultados compilados #divisoes <- sprintf("%02d",CNAE95$"Código") # for (ano in anos) { # for (uf in ufs) { # rais <- read_RAIS("vinculos", i = ano, UF = uf, root_path = "~/RLocalData/", vars_subset = c("CNAE 95 Classe","Faixa Remun M\xe9dia (SM)")) # rais$"CNAE 95 Classe" <- sprintf("%05d",parse_number(rais$"CNAE 95 Classe")) # for (divisao in divisoes){ # linhas <- substr(rais$"CNAE 95 Classe",1,2) == divisao # raisocupas <- rais[linhas,] # raisocupas$"Faixa Remun M\xe9dia (SM)" <- as.numeric(raisocupas$"Faixa Remun M\xe9dia (SM)") # seden <- nrow(raisocupas) # if (nrow(raisocupas) == 0) { seden = 1 } # raissuper <- raisocupas[ raisocupas$"Faixa Remun M\xe9dia (SM)" <= 3] # senum <- nrow(raissuper) # superexp <- senum/seden # novovalor <- data.frame(ano, uf, divisao,superexp,nrow(raisocupas)) # names(novovalor) <- nomescols # proxysuper <- rbind(proxysuper,novovalor) # } # write.csv2(proxysuper,paste0("data/seriesuperexp",anos[1],"-",ano,".csv")) # gc() # } # } #############ROTATIVIDADE rotatproxy <- data.frame(matrix(ncol = 5, nrow = 0)) for (ano in anos) { for (uf in ufs) { rais <- read_RAIS("vinculos", i = ano, UF = uf, root_path = "~/RLocalData/RAIS", vars_subset = c("M\xeas Desligamento","Tempo Emprego")) names(rais) <- c("desligadoem","tempo_emprego") rais$tempo_emprego <- as.numeric(gsub(",",".",rais$tempo_emprego)) vtotais <- nrow(rais) rodaram <- rais[rais$desligadoem > 0] numrod <- nrow(rodaram) rodano <- nrow(rodaram[rodaram$tempo_emprego < 12]) novovalor <- data.frame(ano, uf, rodano,numrod,vtotais) names(novovalor) <- c("ano","uf","desligateum","desligados","vinculostotais") rotatproxy <- rbind(rotatproxy,novovalor) } write.csv2(rotatproxy,paste0("data/rotatividade",anos[1],"-",ano,".csv")) gc() } rotatproxysum <- rotatproxy %>% group_by (ano) %>% summarise(desligateum = sum(desligateum)*100/sum(desligados),desligados = sum(desligados)*100/sum(vinculostotais), vinculostotais = sum(vinculostotais)) rotatproxysum$ano <- as.Date(paste(rotatproxysum$ano,"1231"),"%Y%m%d") ######tentativa de gráfico com plotly ay <- list( tickfont = list(color = "tomato4"), overlaying = "y", side = "right", title = "(%)" ) graficorotatividade <- plot_ly() %>% add_lines(x = rotatproxysum$ano, y = rotatproxysum$desligados, name = "Desligamentos/Total Vínculos", color = "tomato" ) %>% add_lines(x = rotatproxysum$ano, y = rotatproxysum$desligateum, name = "Desligamentos até 1 ano (% Desl.)", yaxis = "y2", color = "tomato4") %>% layout( # title = "Indicadores de Rotatividade\n Mercado Formal de Trabalho\nBrasil - 1994 a 2017 (%)", yaxis = list(title = "(%)"), yaxis2 = ay, xaxis = list(title="Ano") ) ###########CAGED cagedanos <- paste0("2018","-",sprintf("%02d",seq(1,09,1)),"m") for (anocg in cagedanos) { download_sourceData("CAGED", i = anocg, replace = T, root_path = "~/RLocalData/CAGED/") } # download.file("https://raw.githubusercontent.com/guilhermejacob/guilhermejacob.github.io/master/scripts/mtps.R", "Nacional-Brasil/mtps.R") cagedb <- datavault_mtps(catalog) ###DIEESE ###https://www.dieese.org.br/canal/autenticaUsuario.do?login=internet&senha=gujeihee&sistema=xserve3
4,840
gpl-3.0
8bf2fe8aadea5020a30fa05df30d630b5364a527
droglenc/FSAdata
R/WalleyeML.R
#' @title Back-calculated lengths-at-age for Walleye from Lake Mille Lacs, 2000-2011. #' #' @description Back-calculated lengths-at-age for Walleye (\emph{Sander vitreus}) from Lake Mille Lacs. Walleye were captured by Minnesota Department of Natural Resources personnel in fishery-independent gillnets (five multifilament nylon mesh panels with each panel measuring 15.2 m wide and 1.8 m high; bar-measure mesh sizes of the panels were 19.1, 25.4, 31.7, 38.1, and 50.8 mm) set in the fall (mid September to early October) from 2000 to 2011. #' #' @name WalleyeML #' #' @docType data #' #' @format A data frame of 14583 observations on the following 9 variables: #' \describe{ #' \item{ID}{A unique fish identification number.} #' \item{Year}{Year of data.} #' \item{Sex}{Sex (female, male).} #' \item{Est.Age}{Estimated (from otoliths) age (yrs) at capture.} #' \item{TL}{Total length (mm).} #' \item{Scale.Rad}{Total scale radius (mm) at capture.} #' \item{Dist.Ann}{Scale radius (mm) to annulus given in \code{BC.Age}.} #' \item{BC.Age}{Annulus or previous age.} #' \item{BC.Len}{Back-calculated length at \code{BC.Age}. Lengths were back-calculated using the \emph{Scale-Proportional Hypothesis} method.} #' } #' #' @section Topic(s): #' \itemize{ #' \item Growth #' \item von Bertalanffy #' \item Back-calculation #' } #' #' @concept Growth #' @concept von Bertalanffy #' @concept Back-calculation #' #' @source These unpublished data are from the Minnesota Department of Natural Resources, Section of Fisheries (via Melissa Treml). \bold{Do not use for other than educational purposes without permission from the source.} #' #' @keywords datasets #' #' @examples #' data(WalleyeML) #' str(WalleyeML) #' head(WalleyeML) #' xtabs(~Year+Est.Age+Sex,data=WalleyeML) #' NULL
1,814
gpl-2.0
090d3b50284625678ba48692154d8e7c87f3033e
kmillar/cxxr
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
090d3b50284625678ba48692154d8e7c87f3033e
ArunChauhan/cxxr
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
a9000c7685f7d849fe0a4cff1af1bf39c345ec9d
tdsmith/git2r
tests/status.R
## git2r, R bindings to the libgit2 library. ## Copyright (C) 2013-2015 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, ## as published by the Free Software Foundation. ## ## git2r is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. library(git2r) ## ## Create a directory in tempdir ## path <- tempfile(pattern="git2r-") dir.create(path) ## ## Initialize a repository ## repo <- init(path) config(repo, user.name="Alice", user.email="alice@example.org") ## ## Status case 1 ## status_exp_1 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list(), .Names = character(0))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_1 <- status(repo) str(status_exp_1) str(status_obs_1) stopifnot(identical(status_obs_1, status_exp_1)) ## ## Status case 2, include ignored files ## status_exp_2 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list(), .Names = character(0)), ignored = structure(list(), .Names = character(0))), .Names = c("staged", "unstaged", "untracked", "ignored"), class = "git_status") status_obs_2 <- status(repo, ignored=TRUE) str(status_exp_2) str(status_obs_2) stopifnot(identical(status_obs_2, status_exp_2)) ## ## Create 4 files ## writeLines("File-1", file.path(path, "test-1.txt")) writeLines("File-2", file.path(path, "test-2.txt")) writeLines("File-3", file.path(path, "test-3.txt")) writeLines("File-4", file.path(path, "test-4.txt")) ## ## Status case 3: 4 untracked files ## status_exp_3 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list( untracked = "test-1.txt", untracked = "test-2.txt", untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked", "untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_3 <- status(repo) str(status_exp_3) str(status_obs_3) stopifnot(identical(status_obs_3, status_exp_3)) ## ## Add file 1 and 2 to the repository and commit ## add(repo, c("test-1.txt", "test-2.txt")) commit(repo, "Commit message") ## ## Status case 4: 2 untracked files ## status_exp_4 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list( untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_4 <- status(repo) str(status_exp_4) str(status_obs_4) stopifnot(identical(status_obs_4, status_exp_4)) ## ## Update file 1 & 2 ## writeLines(c("File-1", "Hello world"), file.path(path, "test-1.txt")) writeLines(c("File-2", "Hello world"), file.path(path, "test-2.txt")) ## ## Add file 1 ## add(repo, "test-1.txt") ## ## Status case 5: 1 staged file, 1 unstaged file and 2 untracked files ## status_exp_5 <- structure(list(staged = structure(list(modified = "test-1.txt"), .Names = "modified"), unstaged = structure(list(modified = "test-2.txt"), .Names = "modified"), untracked = structure(list(untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_5 <- status(repo) str(status_exp_5) str(status_obs_5) stopifnot(identical(status_obs_5, status_exp_5)) ## ## Add .gitignore file with file test-4.txt ## writeLines("test-4.txt", file.path(path, ".gitignore")) ## ## Status case 6: 1 staged file, 1 unstaged file, 2 untracked files and 1 ignored file ## status_exp_6 <- structure(list(staged = structure(list(modified = "test-1.txt"), .Names = "modified"), unstaged = structure(list(modified = "test-2.txt"), .Names = "modified"), untracked = structure(list(untracked = ".gitignore", untracked = "test-3.txt"), .Names = c("untracked", "untracked")), ignored = structure(list(ignored = "test-4.txt"), .Names = "ignored")), .Names = c("staged", "unstaged", "untracked", "ignored"), class = "git_status") status_obs_6 <- status(repo, ignore=TRUE) str(status_exp_6) str(status_obs_6) stopifnot(identical(status_obs_6, status_exp_6)) ## ## Cleanup ## unlink(path, recursive=TRUE)
5,957
gpl-2.0
d57b15171a11186a1ce0ac1a10fefe167abff420
STAT-ATA-ASU/Arnholt-Alan-STT2810
R-Scripts/rscriptpractice.R
# Alan Arnholt # 9/15/15 library(PASWR2) ?EPIDURALF str(EPIDURALF) head(EPIDURALF) # shows first six rows 116/(172/100)^2 library(dplyr) # puts package on search path bodyfat <- select(EPIDURALF, kg, cm) head(bodyfat) bodyfat <- mutate(bodyfat, BMI = kg/(cm/100)^2) head(bodyfat) bodyfat2 <- filter(bodyfat, BMI > 45) head(bodyfat2) arrange(bodyfat2, BMI) # epi1 <- select(EPIDURALF, doctor, oc, ease) epi1 epi2 <- filter(epi1, oc >= 5) head(epi2) xtabs(~doctor + ease, data = epi2) library(MASS) ?quine filter(quine, Lrn == "AL", Days > 5) library(ggplot2) ggplot(data = quine, aes(x = Sex, y = Days)) + geom_boxplot() + facet_grid(Eth ~ Lrn)
652
mit
090d3b50284625678ba48692154d8e7c87f3033e
kmillar/rho
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
090d3b50284625678ba48692154d8e7c87f3033e
rho-devel/rho
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
090d3b50284625678ba48692154d8e7c87f3033e
cxxr-devel/cxxr
src/extra/testr/filtered-test-suite/rowsum/tc_rowsum_5.R
expected <- eval(parse(text="structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Dim = c(8L, 1L), .Dimnames = list(c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), NULL))")); test(id=0, code={ argv <- eval(parse(text="list(structure(c(0.102430555555556, 0.102430555555556, 0.102430555555556, 0.546875, -0.078125, 0.477430555555556, -0.0642361111111111, 0.102430555555556), .Names = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\")), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), structure(1:8, .Label = c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"), class = \"factor\"), FALSE, c(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"))")); .Internal(rowsum_matrix(argv[[1]], argv[[2]], argv[[3]], argv[[4]], argv[[5]])); }, o=expected);
962
gpl-2.0
5eb0264ad1d50b573e3659165ba1e5c02c729bee
kbseah/genome-bin-tools
gbtools/R/summary.gbt.R
#' Print summary of gbt object #' #' @param x Object of class gbt #' @return data.frame summarizing contents of x #' @seealso \code{\link{gbt}}, \code{\link{print.gbt}} #' @export summary.gbt <- print.gbt # Identical to "print" behavior
238
gpl-2.0
a9000c7685f7d849fe0a4cff1af1bf39c345ec9d
egonw/git2r
tests/status.R
## git2r, R bindings to the libgit2 library. ## Copyright (C) 2013-2015 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, ## as published by the Free Software Foundation. ## ## git2r is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. library(git2r) ## ## Create a directory in tempdir ## path <- tempfile(pattern="git2r-") dir.create(path) ## ## Initialize a repository ## repo <- init(path) config(repo, user.name="Alice", user.email="alice@example.org") ## ## Status case 1 ## status_exp_1 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list(), .Names = character(0))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_1 <- status(repo) str(status_exp_1) str(status_obs_1) stopifnot(identical(status_obs_1, status_exp_1)) ## ## Status case 2, include ignored files ## status_exp_2 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list(), .Names = character(0)), ignored = structure(list(), .Names = character(0))), .Names = c("staged", "unstaged", "untracked", "ignored"), class = "git_status") status_obs_2 <- status(repo, ignored=TRUE) str(status_exp_2) str(status_obs_2) stopifnot(identical(status_obs_2, status_exp_2)) ## ## Create 4 files ## writeLines("File-1", file.path(path, "test-1.txt")) writeLines("File-2", file.path(path, "test-2.txt")) writeLines("File-3", file.path(path, "test-3.txt")) writeLines("File-4", file.path(path, "test-4.txt")) ## ## Status case 3: 4 untracked files ## status_exp_3 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list( untracked = "test-1.txt", untracked = "test-2.txt", untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked", "untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_3 <- status(repo) str(status_exp_3) str(status_obs_3) stopifnot(identical(status_obs_3, status_exp_3)) ## ## Add file 1 and 2 to the repository and commit ## add(repo, c("test-1.txt", "test-2.txt")) commit(repo, "Commit message") ## ## Status case 4: 2 untracked files ## status_exp_4 <- structure(list(staged = structure(list(), .Names = character(0)), unstaged = structure(list(), .Names = character(0)), untracked = structure(list( untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_4 <- status(repo) str(status_exp_4) str(status_obs_4) stopifnot(identical(status_obs_4, status_exp_4)) ## ## Update file 1 & 2 ## writeLines(c("File-1", "Hello world"), file.path(path, "test-1.txt")) writeLines(c("File-2", "Hello world"), file.path(path, "test-2.txt")) ## ## Add file 1 ## add(repo, "test-1.txt") ## ## Status case 5: 1 staged file, 1 unstaged file and 2 untracked files ## status_exp_5 <- structure(list(staged = structure(list(modified = "test-1.txt"), .Names = "modified"), unstaged = structure(list(modified = "test-2.txt"), .Names = "modified"), untracked = structure(list(untracked = "test-3.txt", untracked = "test-4.txt"), .Names = c("untracked", "untracked"))), .Names = c("staged", "unstaged", "untracked"), class = "git_status") status_obs_5 <- status(repo) str(status_exp_5) str(status_obs_5) stopifnot(identical(status_obs_5, status_exp_5)) ## ## Add .gitignore file with file test-4.txt ## writeLines("test-4.txt", file.path(path, ".gitignore")) ## ## Status case 6: 1 staged file, 1 unstaged file, 2 untracked files and 1 ignored file ## status_exp_6 <- structure(list(staged = structure(list(modified = "test-1.txt"), .Names = "modified"), unstaged = structure(list(modified = "test-2.txt"), .Names = "modified"), untracked = structure(list(untracked = ".gitignore", untracked = "test-3.txt"), .Names = c("untracked", "untracked")), ignored = structure(list(ignored = "test-4.txt"), .Names = "ignored")), .Names = c("staged", "unstaged", "untracked", "ignored"), class = "git_status") status_obs_6 <- status(repo, ignore=TRUE) str(status_exp_6) str(status_obs_6) stopifnot(identical(status_obs_6, status_exp_6)) ## ## Cleanup ## unlink(path, recursive=TRUE)
5,957
gpl-2.0
d57b15171a11186a1ce0ac1a10fefe167abff420
STT2810-ASU/Arnholt-Alan-STT2810
R-Scripts/rscriptpractice.R
# Alan Arnholt # 9/15/15 library(PASWR2) ?EPIDURALF str(EPIDURALF) head(EPIDURALF) # shows first six rows 116/(172/100)^2 library(dplyr) # puts package on search path bodyfat <- select(EPIDURALF, kg, cm) head(bodyfat) bodyfat <- mutate(bodyfat, BMI = kg/(cm/100)^2) head(bodyfat) bodyfat2 <- filter(bodyfat, BMI > 45) head(bodyfat2) arrange(bodyfat2, BMI) # epi1 <- select(EPIDURALF, doctor, oc, ease) epi1 epi2 <- filter(epi1, oc >= 5) head(epi2) xtabs(~doctor + ease, data = epi2) library(MASS) ?quine filter(quine, Lrn == "AL", Days > 5) library(ggplot2) ggplot(data = quine, aes(x = Sex, y = Days)) + geom_boxplot() + facet_grid(Eth ~ Lrn)
652
mit
bce508c273f60ac954d6a7a0dae7f0e6e34a8501
chipster/chipster-tools
tools/misc/R/my_tblastn.R
# TOOL my_tblastn.R: "Translated protein BLAST against users of nucleotide sequence set" (Heuristic tool to search hits from users own nucleotide sequence set using protein query. Your query sequence set can contain 100000 nucleotide sequences in maximum.) # INPUT query.fa: "Query sequences" TYPE GENERIC # INPUT dbnuc.fa: "Database sequences" TYPE GENERIC # OUTPUT OPTIONAL blast_results.txt # OUTPUT OPTIONAL blast_results.xml # OUTPUT OPTIONAL blast_results.tsv # OUTPUT OPTIONAL blast_results.fasta # OUTPUT OPTIONAL blast_results.csv # OUTPUT OPTIONAL blast_results.asn1 # OUTPUT OPTIONAL blast_results.html # OUTPUT OPTIONAL blast.log # PARAMETER OPTIONAL evalue: "Expectation threshold for saving hits" TYPE DECIMAL DEFAULT 10 (E-value specifies the statistical significance threshold for reporting matches against database sequences. The default value 10 means that 10 such matches are expected to be found merely by chance. Lower thresholds are more stringent, leading to fewer chance matches being reported.) # PARAMETER OPTIONAL db_gencode: "Genetic code" TYPE [1: "Standard", 2: "Vertebrate Mitochondrial", 3: "Yeast Mitochondrial", 4: "Mold Mitochondrial", 5: "Invertebrate Mitochondrial", 6: "Ciliate Nuclear", 9: "Echinoderm Mitochondrial", 10: "Euploid Nuclear", 11: "Bacteria and Archaea", 12: "Alternative Yeast Nuclear", 13: "Ascidian Mitochodrial", 14: "Flatworm Mitochondrial", 15: "Blepharisma Macronuclear"] DEFAULT 1 (Genetic code to use to translate query.) # PARAMETER OPTIONAL word_size: "Word size" TYPE INTEGER FROM 2 TO 10 DEFAULT 3 (The length of the seed that initiates an alignment. BLAST works by finding word-matches between the query and database sequences. One may think of this process as finding hot-spots that BLAST can then use to initiate extensions that might eventually lead to full-blown alignments. For BLASTP searches non-exact word matches are taken into account based upon the similarity between words. The amount of similarity can be varied so one normally uses just the word-sizes 2 and 3 for these searches.) # PARAMETER OPTIONAL num_hits: "Maximun number of hits to collect per sequence" TYPE INTEGER DEFAULT 100 (Number of database sequences to show one-line descriptions for.) # PARAMETER OPTIONAL outfmt: "Output format type" TYPE [0: "normal BLAST report with pairwise alignments", 1: "query-anchored alignments showing identities", 2: "query-anchored alignments with no identities", 3: "flat query-anchored, show identities", 4: "flat query-anchored, no identities", 5: "XML Blast output", 6: "tabular", 10: "comma-separated values", 11: "BLAST archive format", 13: "Hit sequences in fasta format", 14: "hit regions in fasta format"] DEFAULT 0 (Output format type) # PARAMETER OPTIONAL seg: "Filter low complexity regions" TYPE [yes: Yes, no: No] DEFAULT yes (Use SEG program for filtering low cmoplexity regions in the query sequence) # PARAMETER OPTIONAL entrez_query: "Entrez query to limit search" TYPE STRING DEFAULT "none" (You can use Entrez query syntax to search a subset of the selected BLAST database. This can be helpful to limit searches to molecule types, sequence lengths or to exclude organisms.) # PARAMETER OPTIONAL query_loc: "Location on the query sequence" TYPE STRING DEFAULT "full length" (Location of the search region in the query sequence, for example: 23-66.) # PARAMETER OPTIONAL max_intron_length: "Length of the largest intron allowed" TYPE INTEGER DEFAULT 0 ( Length of the largest intron allowed in a translated nucleotide sequence when linking multiple distinct alignments. A negative value disables linking) # PARAMETER OPTIONAL matrix: "Matrix" TYPE [BLOSUM45: "BLOSUM45", BLOSUM50: "BLOSUM50", BLOSUM62: "BLOSUM62", BLOSUM80: "BLOSUM80", BLOSUM90: "BLOSUM90"] DEFAULT BLOSUM62 (Weight matrix assigns a score for aligning pairs of residues, and determines overall alignment score. Experimentation has shown that the BLOSUM62 matrix is among the best for detecting most weak protein similarities. For particularly long and weak alignments, the BLOSUM45 matrix may prove superior. For proteins, shorter than 85 resdues, the BLOSUM80 matrix may provide better hits" ) # PARAMETER OPTIONAL gapopen: "Gap opening penalty" TYPE STRING DEFAULT "default" (Cost to open a gap. Integer value from 6 to 25. The default value of this parameter depends on the selected scoring matrix. Note that if you assign this value, you must define also the gap extension penalty ) # PARAMETER OPTIONAL gapextend: "Gap extension penalty" TYPE STRING DEFAULT "default" (Gap extension penalty Integer value from 1 to 3.The default value of this parameter depends on the selected scoring matrix. Note that if you assign this value, you must define also the gap opening penalty ) # PARAMETER OPTIONAL save_log: "Output a log file" TYPE [yes: yes, no: no] DEFAULT no (Collect a log file for the BLAST run.) # KM 24.10.2013 # check out if the file is compressed and if so unzip it source(file.path(chipster.common.path, "zip-utils.R")) unzipIfGZipFile("query.fa") unzipIfGZipFile("dbprot.fa") # pb settings pb.binary <- file.path(chipster.module.path, "/shell/pb_for_chipster.sh") #pb.binary <- file.path(chipster.tools.path, "blast", "/ncbi-blast-2.2.29+", "bin", "pb_for_chipster") command.start <- paste(pb.binary, "tblastn") emboss.path <- file.path(chipster.tools.path, "emboss" ,"bin") #check sequece file type inputfile.to.check <- ("query.fa") sfcheck.binary <- file.path(chipster.module.path ,"/shell/sfcheck.sh") sfcheck.command <- paste(sfcheck.binary, emboss.path, inputfile.to.check ) str.filetype <- system(sfcheck.command, intern = TRUE ) if ( str.filetype == "Not an EMBOSS compatible sequence file"){ stop("CHIPSTER-NOTE: Your input file is not a sequence file that is compatible with the tool you try to use") } #count the query sequeces seqcount.exe <- file.path(emboss.path, "seqcount -filter query.fa") str.queryseq <- system(seqcount.exe, intern = TRUE ) num.queryseq <- as.integer(str.queryseq) #In blast command outputformat is used as a string #in job control as a number outfmt.string <- outfmt outfmt <- as.integer(outfmt) #round(num.queryseq) if (num.queryseq > 100000){ stop(paste('Too many query sequences. Maximun is 100000 but your file contains ', num.queryseq )) } #Modify table format outfmt.is.table <- paste("no") if (outfmt == 6) { outfmt.string <- paste('"6 qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore stitle"') outfmt.is.table <- paste("yes") } #These parameters have allways some value general.parameters <- paste("-chipster_path /opt/chipster -no_slurm -query query.fa -out blast_results -dbnuc dbnuc.fa -db_gencode", db_gencode, "-evalue ", evalue, "-matrix", matrix, "-word_size" , word_size , "-seg" , seg , "-outfmt" , outfmt.string, "-max_intron_length", max_intron_length) general.parameters <- paste( general.parameters, "-num_threads" , chipster.threads.max ) optional.parameters <- paste(" ") if (outfmt < 5) { optional.parameters <- paste(optional.parameters, " -html -num_descriptions ", num_hits, "-num_alignments", num_hits ) } if (outfmt > 5) { optional.parameters <- paste(optional.parameters, " -max_target_seqs ", num_hits ) } #Check text formatted parameters if (nchar(gapopen) > 2 ) { gapopen <- paste("default") } if (nchar(gapopen) < 1 ) { gapopen <- paste("default") } if (nchar(gapextend) > 2 ) { gapextend <- paste("default") } if (nchar(gapextend) < 1 ) { gapextend <- paste("default") } if (nchar(query_loc) < 3 ) { penalty <- paste("full length") } if ( gapopen != "default" ) { if ( gapextend == "default" ){ stop(paste("If you define gap opening penalty you must also define gap extension pelalty")) } } if ( gapextend != "default" ) { if ( gapopen == "default" ){ stop(paste("If you define gap opening penalty you must also define gap extension pelalty")) } } if ( gapopen != "default"){ if ( gapextend != "default" ){ optional.parameters <- paste(optional.parameters, " -gapopen ", gapopen, "-gapextend" , gapextend ) } } if ( query_loc != "full length"){ optional.parameters <- paste(optional.parameters, " -query_loc ", query_loc ) } command.end <- (paste(" >>", "blast.log 2>&1")) #run the task system("ls -l > blast.log") blast.command <- paste(command.start, general.parameters, optional.parameters, command.end) echo.command <- paste("echo '", blast.command , "' >> blast.log" ) system(echo.command) system(blast.command) system("echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") system("ls -l >> blast.log") #rename the results if (outfmt < 5) { test.command <- paste("echo renaming as html. outformat is ", outfmt, ">> blast.log") system (test.command) system ("mv blast_results blast_results.html") } if (outfmt == 5) { system ("mv blast_results blast_results.xml") } if (outfmt.is.table == "yes") { system ('printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" "query id" "subject id" "identity percent" "alignment length" mismatches "gap opens" "query start" "query end" "subject start" "subject end" evalue "bit score" "subject description"> blast_results.tsv ') system ("cat blast_results >> blast_results.tsv") } if (outfmt == 7) { system ("mv blast_results blast_results.tsv") } if (outfmt == 8) { system ("mv blast_results blast_results.txt") } if (outfmt == 10) { system ("mv blast_results blast_results.csv") } if (outfmt == 11) { system ("mv blast_results blast_results.asn1") } if (outfmt == 12) { system ("mv blast_results blast_results.txt") } if (outfmt == 13) { system ("mv blast_results blast_results.fasta") } if (outfmt == 14) { system ("mv blast_results blast_results.fasta") } if ( save_log == "no") { system ("rm -f blast.log") }
9,744
mit
67a9ac226f637facafd9f93943bdf0d5c5f6c615
mumtahena/bild_signatures
BH3_Stuff/Mcl1Dependence_Xiao.R
# This scripts analyzes the difference bettwen MCL-1 dependent and independent cell lines setwd("~/Documents/Multipathway_Modeling/") source("http://www.r-statistics.com/wp-content/uploads/2010/02/Barnard.R.txt") source("http://www.r-statistics.com/wp-content/uploads/2012/01/source_https.r.txt") source_https("https://raw.github.com/talgalili/R-code-snippets/master/Barnard.R") MCLdata=read.csv("Mcl1_Xiao_Data.txt",header = T,sep='\t')[1:23,1:5] View(MCLdata) colnames(MCLdata) MCLdata[1:13,4] boxplot(MCLdata[1:14,4],MCLdata[15:23,4], ylab="% Viability upon treatment (MCL-1 siRNA)",names = c("AKT Phenotype \n n=14", " EGFR Phenotype \n n=9"), col = c("red", "grey"), main="Mcl-1 Dependence Across Growth Phenotypes", ylim=c(0,100)) text(1,2,"p-value = 0.095") t.test(MCLdata[1:14,4],MCLdata[15:23,4]) MclDependence<- matrix(c(9,2,5,7), nrow=2, dimnames=list(c("EGFR", "AKT"), c("Mcl Dependent", "Non-Mcl Dependent"))) fisher.test(MclDependence) fisher.test(MclDependence, alternative = "greater") View(MclDependence) Barnard(MclDependence) TeaTasting <- matrix(c(3, 1, 1, 3), nrow = 2, dimnames = list(Guess = c("Milk", "Tea"), Truth = c("Milk", "Tea"))) View(TeaTasting) fisher.test(TeaTasting, alternative = "greater") Convictions <- matrix(c(2, 10, 15, 3), nrow = 2, dimnames = list(c("Dizygotic", "Monozygotic"), c("Convicted", "Not convicted"))) View(Convictions)
1,480
mit
aeaa968235995317de4ff15176a08e0ae2ec27eb
Blahah/assemblotron-paper
figures/yeast_fulldata_optimisation_sim.R
library(data.table) library(dplyr) library(ggplot2) library(reshape2) library(gridExtra) setwd('~/code/assemblotron-paper/data/optimisation_simulation/') dt <- NULL for (csv in dir(pattern='*/*_scores.csv', recursive = T)) { this_dt <- fread(csv) rep <- gsub('.*/(.*)_scores.csv', '\\1', csv) species <- gsub('(.*)/.*_scores.csv', '\\1', csv) this_dt[, rep := rep] this_dt[, species := species] if (is.null(dt)) { dt <- this_dt } else { dt <- rbind(dt, this_dt) } } stderr <- function(x) sd(x)/sqrt(length(x)) best <- group_by(dt, species, iteration) %>% summarise(med=median(best), up=quantile(best, 0.95), down=quantile(best, 0.05)) best$type <- 'Best score' score <- group_by(dt, species, iteration) %>% summarise(med=median(score), up=quantile(score, 0.95), down=quantile(score, 0.05)) score$type <- 'Current score' score_plot <- rbind(best, score) %>% ggplot(aes(x=iteration, y=med, colour=species, ymin=down, ymax=up)) + geom_pointrange() + xlab('Assemblies performed') + ylab('Transrate score (median over 100 runs)') + facet_grid(type~.) + theme_bw() ggsave(plot = score_plot, filename = "../../figures/tabu_optimisation_sim.png")
1,212
mit
8a5cb5c8f4f5cd6e8dcfdde93a626aadc0a19de4
RevolutionAnalytics/RRO
R-src/src/library/tools/R/build.R
# File src/library/tools/R/build.R # Part of the R package, https://www.R-project.org # # Copyright (C) 1995-2015 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # A copy of the GNU General Public License is available at # https://www.R-project.org/Licenses/ #### R based engine for R CMD build ## R developers can use this to debug the function by running it ## directly as tools:::.build_packages(args), where the args should ## be what commandArgs(TRUE) would return, that is a character vector ## of (space-delimited) terms that would be passed to R CMD build. writeDefaultNamespace <- function(filename, desc = file.path(dirname(filename), "DESCRIPTION")) { pkgInfo <- .split_description(.read_description(desc)) pkgs <- unique(c(names(pkgInfo$Imports), names(pkgInfo$Depends))) pkgs <- pkgs[pkgs != "base"] writeLines(c("# Default NAMESPACE created by R", "# Remove the previous line if you edit this file", "", "# Export all names", "exportPattern(\".\")", if (length(pkgs)) c("", "# Import all packages listed as Imports or Depends", "import(", paste(" ", pkgs, collapse = ",\n"), ")")), filename) } ### formerly Perl R::Utils::get_exclude_patterns ## Return list of file patterns excluded by R CMD build and check. ## Kept here so that we ensure that the lists are in sync, but not exported. ## Has Unix-style '/' path separators hard-coded, but that is what dir() uses. get_exclude_patterns <- function() c("^\\.Rbuildignore$", "(^|/)\\.DS_Store$", "^\\.(RData|Rhistory)$", "~$", "\\.bak$", "\\.swp$", "(^|/)\\.#[^/]*$", "(^|/)#[^/]*#$", ## Outdated ... "^TITLE$", "^data/00Index$", "^inst/doc/00Index\\.dcf$", ## Autoconf "^config\\.(cache|log|status)$", "(^|/)autom4te\\.cache$", # ncdf4 had this in subdirectory 'tools' ## Windows dependency files "^src/.*\\.d$", "^src/Makedeps$", ## IRIX, of some vintage "^src/so_locations$", ## Sweave detrius "^inst/doc/Rplots\\.(ps|pdf)$" ) ### based on Perl build script .build_packages <- function(args = NULL) { ## this requires on Windows sh make WINDOWS <- .Platform$OS.type == "windows" Sys.umask("022") # Perl version did not have this. writeLinesNL <- function(text, file) { ## a version that uses NL line endings everywhere con <- file(file, "wb") on.exit(close(con)) writeLines(text, con) } ## This version of system_with_capture merges stdout and stderr ## Used to run R to install package and build vignettes. system_with_capture <- function (command, args) { outfile <- tempfile("xshell") on.exit(unlink(outfile)) status <- system2(command, args, outfile, outfile) list(status = status, stdout = readLines(outfile, warn = FALSE)) } ## Run silently Ssystem <- function(command, args = character(), ...) system2(command, args, stdout = NULL, stderr = NULL, ...) do_exit <- function(status = 1L) q("no", status = status, runLast = FALSE) env_path <- function(...) file.path(..., fsep = .Platform$path.sep) ## Used for BuildVignettes, BuildManual, BuildKeepEmpty, ## and (character not logical) BuildResaveData parse_description_field <- function(desc, field, default = TRUE, logical = TRUE) { tmp <- desc[field] if (is.na(tmp)) default else if(logical) switch(tmp, "yes"=, "Yes" =, "true" =, "True" =, "TRUE" = TRUE, "no" =, "No" =, "false" =, "False" =, "FALSE" = FALSE, default) else tmp } Usage <- function() { cat("Usage: R CMD build [options] pkgdirs", "", "Build R packages from package sources in the directories specified by", sQuote("pkgdirs"), "", "Options:", " -h, --help print short help message and exit", " -v, --version print version info and exit", "", " --force force removal of INDEX file", " --keep-empty-dirs do not remove empty dirs", " --no-build-vignettes do not (re)build package vignettes", " --no-manual do not build the PDF manual even if \\Sexprs are present", " --resave-data= re-save data files as compactly as possible:", ' "no", "best", "gzip" (default)', " --resave-data same as --resave-data=best", " --no-resave-data same as --resave-data=no", " --compact-vignettes= try to compact PDF files under inst/doc:", ' "no" (default), "qpdf", "gs", "gs+qpdf", "both"', " --compact-vignettes same as --compact-vignettes=qpdf", " --md5 add MD5 sums", "", "Report bugs at bugs.r-project.org .", sep = "\n") } add_build_stamp_to_description_file <- function(ldpath, pkgdir) { db <- .read_description(ldpath) if(is.na(db["NeedsCompilation"])) db["NeedsCompilation"] <- if(dir.exists(file.path(pkgdir, "src"))) "yes" else "no" ## this is an optional function, so could fail user <- Sys.info()["user"] if(user == "unknown") user <- Sys.getenv("LOGNAME") db["Packaged"] <- sprintf("%s; %s", format(Sys.time(), '', tz = 'UTC', usetz = TRUE), user) .write_description(db, ldpath) } ## <FIXME> ## This should really be combined with ## add_build_stamp_to_description_file(). ## Also, the build code reads DESCRIPTION files too often ... add_expanded_R_fields_to_description_file <- function(ldpath) { db <- .read_description(ldpath) fields <- .expand_package_description_db_R_fields(db) if(length(fields)) .write_description(c(db, fields), ldpath) } ## </FIXME> temp_install_pkg <- function(pkgdir, libdir) { dir.create(libdir, mode = "0755", showWarnings = FALSE) ## assume vignettes only need one arch if (WINDOWS) { cmd <- file.path(R.home("bin"), "Rcmd.exe") args <- c("INSTALL -l", shQuote(libdir), "--no-multiarch", shQuote(pkgdir)) } else { cmd <- file.path(R.home("bin"), "R") args <- c("CMD", "INSTALL -l", shQuote(libdir), "--no-multiarch", shQuote(pkgdir)) } res <- system_with_capture(cmd, args) if (res$status) { printLog(Log, " -----------------------------------\n") printLog0(Log, paste(c(res$stdout, ""), collapse = "\n")) printLog(Log, " -----------------------------------\n") unlink(libdir, recursive = TRUE) printLog(Log, "ERROR: package installation failed\n") do_exit(1) } Sys.setenv("R_BUILD_TEMPLIB" = libdir) TRUE } prepare_pkg <- function(pkgdir, desc, Log) { owd <- setwd(pkgdir); on.exit(setwd(owd)) ## pkgname <- basename(pkgdir) checkingLog(Log, "DESCRIPTION meta-information") res <- try(.check_package_description("DESCRIPTION")) if (inherits(res, "try-error")) { resultLog(Log, "ERROR") messageLog(Log, "running '.check_package_description' failed") } else { if (any(lengths(res))) { resultLog(Log, "ERROR") print(res) # FIXME print to Log? do_exit(1L) } else resultLog(Log, "OK") } cleanup_pkg(pkgdir, Log) libdir <- tempfile("Rinst") ensure_installed <- function() if (!pkgInstalled) { messageLog(Log, "installing the package to build vignettes") pkgInstalled <<- temp_install_pkg(pkgdir, libdir) } pkgInstalled <- build_Rd_db(pkgdir, libdir, desc) if (file.exists("INDEX")) update_Rd_index("INDEX", "man", Log) doc_dir <- file.path("inst", "doc") if ("makefile" %in% dir(doc_dir)) { # avoid case-insensitive match messageLog(Log, "renaming 'inst/doc/makefile' to 'inst/doc/Makefile'") file.rename(file.path(doc_dir, "makefile"), file.path(doc_dir, "Makefile")) } if (vignettes && parse_description_field(desc, "BuildVignettes", TRUE)) { ## this is not a logical field ## if (nchar(parse_description_field(desc, "VignetteBuilder", ""))) ## ensure_installed() ## PR#15775: check VignetteBuilder packages are installed ## This is a bit wasteful: we do not need them in this process loadVignetteBuilder(pkgdir, TRUE) ## Look for vignette sources vigns <- pkgVignettes(dir = '.', check = TRUE) if (!is.null(vigns) && length(vigns$docs)) { ensure_installed() ## Good to do this in a separate process: it might die creatingLog(Log, "vignettes") R_LIBS <- Sys.getenv("R_LIBS", NA_character_) if (!is.na(R_LIBS)) { on.exit(Sys.setenv(R_LIBS = R_LIBS), add = TRUE) Sys.setenv(R_LIBS = env_path(libdir, R_LIBS)) } else { on.exit(Sys.unsetenv("R_LIBS"), add = TRUE) Sys.setenv(R_LIBS = libdir) } # Tangle all vignettes now. cmd <- file.path(R.home("bin"), "Rscript") args <- c("--vanilla", "--default-packages=", # some vignettes assume methods "-e", shQuote("tools::buildVignettes(dir = '.', tangle = TRUE)")) ## since so many people use 'R CMD' in Makefiles, oPATH <- Sys.getenv("PATH") Sys.setenv(PATH = paste(R.home("bin"), oPATH, sep = .Platform$path.sep)) res <- system_with_capture(cmd, args) Sys.setenv(PATH = oPATH) if (res$status) { resultLog(Log, "ERROR") printLog0(Log, paste(c(res$stdout, ""), collapse = "\n")) do_exit(1L) } else { # Rescan for weave and tangle output files vigns <- pkgVignettes(dir = '.', output = TRUE, source = TRUE) stopifnot(!is.null(vigns)) resultLog(Log, "OK") } ## We may need to install them. if (basename(vigns$dir) == "vignettes") { ## inst may not yet exist dir.create(doc_dir, recursive = TRUE, showWarnings = FALSE) file.copy(c(vigns$docs, vigns$outputs, unlist(vigns$sources)), doc_dir) unlink(c(vigns$outputs, unlist(vigns$sources))) extras_file <- file.path("vignettes", ".install_extras") if (file.exists(extras_file)) { extras <- readLines(extras_file, warn = FALSE) if(length(extras)) { allfiles <- dir("vignettes", all.files = TRUE, full.names = TRUE, recursive = TRUE, include.dirs = TRUE) inst <- rep(FALSE, length(allfiles)) for (e in extras) inst <- inst | grepl(e, allfiles, perl = TRUE, ignore.case = TRUE) file.copy(allfiles[inst], doc_dir, recursive = TRUE) } } } vignetteIndex <- .build_vignette_index(vigns) if(NROW(vignetteIndex) > 0L) { ## remove any files with no R code (they will have header comments). ## if not correctly declared they might not be in the current encoding sources <- vignetteIndex$R for(i in seq_along(sources)) { file <- file.path(doc_dir, sources[i]) if (!file_test("-f", file)) next bfr <- readLines(file, warn = FALSE) if(all(grepl("(^###|^[[:space:]]*$)", bfr, useBytes = TRUE))) { unlink(file) vignetteIndex$R[i] <- "" } } } ## Save the list dir.create("build", showWarnings = FALSE) saveRDS(vignetteIndex, file = file.path("build", "vignette.rds")) } } else { fv <- file.path("build", "vignette.rds") if(file.exists(fv)) { checkingLog(Log, "vignette meta-information") db <- readRDS(fv) pdfs <- file.path("inst", "doc", db[nzchar(db$PDF), ]$PDF) missing <- !file.exists(pdfs) if(any(missing)) { msg <- c("Output(s) listed in 'build/vignette.rds' but not in package:", strwrap(sQuote(pdfs[missing]), indent = 2L, exdent = 2L), "Run R CMD build without --no-build-vignettes to re-create") errorLog(Log, paste(msg, collapse = "\n")) do_exit(1L) } else resultLog(Log, "OK") } } if (compact_vignettes != "no" && length(pdfs <- dir(doc_dir, pattern = "[.]pdf", recursive = TRUE, full.names = TRUE))) { messageLog(Log, "compacting vignettes and other PDF files") if(compact_vignettes %in% c("gs", "gs+qpdf", "both")) { gs_cmd <- find_gs_cmd() gs_quality <- "ebook" } else { gs_cmd <- "" gs_quality <- "none" } qpdf <- ifelse(compact_vignettes %in% c("qpdf", "gs+qpdf", "both"), Sys.which(Sys.getenv("R_QPDF", "qpdf")), "") res <- compactPDF(pdfs, qpdf = qpdf, gs_cmd = gs_cmd, gs_quality = gs_quality) res <- format(res, diff = 1e5) if(length(res)) printLog0(Log, paste(" ", format(res), collapse = "\n"), "\n") } if (pkgInstalled) { unlink(libdir, recursive = TRUE) ## And finally, clean up again. cleanup_pkg(pkgdir, Log) } } cleanup_pkg <- function(pkgdir, Log) { owd <- setwd(pkgdir); on.exit(setwd(owd)) pkgname <- basename(pkgdir) if (dir.exists("src")) { setwd("src") messageLog(Log, "cleaning src") if (WINDOWS) { have_make <- nzchar(Sys.which(Sys.getenv("MAKE", "make"))) if (file.exists("Makefile.win")) { if (have_make) Ssystem(Sys.getenv("MAKE", "make"), "-f Makefile.win clean") else warning("unable to run 'make clean' in 'src'", domain = NA) } else { if (file.exists("Makevars.win")) { if (have_make) { makefiles <- paste() makefiles <- paste("-f", shQuote(file.path(R.home("share"), "make", "clean.mk")), "-f Makevars.win") Ssystem(Sys.getenv("MAKE", "make"), c(makefiles, "clean")) } else warning("unable to run 'make clean' in 'src'", domain = NA) } ## Also cleanup possible Unix leftovers ... unlink(c(Sys.glob(c("*.o", "*.sl", "*.so", "*.dylib")), paste0(pkgname, c(".a", ".dll", ".def")), "symbols.rds")) if (dir.exists(".libs")) unlink(".libs", recursive = TRUE) if (dir.exists("_libs")) unlink("_libs", recursive = TRUE) } } else { makefiles <- paste("-f", shQuote(file.path(R.home("etc"), Sys.getenv("R_ARCH"), "Makeconf"))) if (file.exists("Makefile")) { makefiles <- paste(makefiles, "-f", "Makefile") Ssystem(Sys.getenv("MAKE", "make"), c(makefiles, "clean")) } else { if (file.exists("Makevars")) { ## ensure we do have a 'clean' target. makefiles <- paste(makefiles, "-f", shQuote(file.path(R.home("share"), "make", "clean.mk")), "-f Makevars") Ssystem(Sys.getenv("MAKE", "make"), c(makefiles, "clean")) } ## Also cleanup possible Windows leftovers ... unlink(c(Sys.glob(c("*.o", "*.sl", "*.so", "*.dylib")), paste0(pkgname, c(".a", ".dll", ".def")), "symbols.rds")) if (dir.exists(".libs")) unlink(".libs", recursive = TRUE) if (dir.exists("_libs")) unlink("_libs", recursive = TRUE) } } } setwd(owd) ## It is not clear that we want to do this: INSTALL should do so. ## Also, certain environment variables should be set according ## to 'Writing R Extensions', but were not in Perl version (nor ## was cleanup.win used). if (WINDOWS) { if (file.exists("cleanup.win")) { ## check we have sh.exe first if (nzchar(Sys.which("sh.exe"))) { Sys.setenv(R_PACKAGE_NAME = pkgname) Sys.setenv(R_PACKAGE_DIR = pkgdir) Sys.setenv(R_LIBRARY_DIR = dirname(pkgdir)) messageLog(Log, "running 'cleanup.win'") Ssystem("sh", "./cleanup.win") } } } else if (file_test("-x", "cleanup")) { Sys.setenv(R_PACKAGE_NAME = pkgname) Sys.setenv(R_PACKAGE_DIR = pkgdir) Sys.setenv(R_LIBRARY_DIR = dirname(pkgdir)) messageLog(Log, "running 'cleanup'") Ssystem("./cleanup") } } update_Rd_index <- function(oldindex, Rd_files, Log) { newindex <- tempfile() res <- try(Rdindex(Rd_files, newindex)) if (inherits(res, "try-error")) { errorLog(Log, "computing Rd index failed") do_exit(1L) } checkingLog(Log, "whether ", sQuote(oldindex), " is up-to-date") if (file.exists(oldindex)) { ol <- readLines(oldindex, warn = FALSE) # e.g. BaM had missing final NL nl <- readLines(newindex) if (!identical(ol, nl)) { resultLog(Log, "NO") if (force) { messageLog(Log, "removing ", sQuote(oldindex), " as '--force' was given") unlink(oldindex) } else { messageLog(Log, "use '--force' to remove ", "the existing ", sQuote(oldindex)) unlink(newindex) } } else { resultLog(Log, "OK") unlink(newindex) } } else { resultLog(Log, "NO") messageLog(Log, "creating new ", sQuote(oldindex)) file.rename(newindex, oldindex) } } build_Rd_db <- function(pkgdir, libdir, desc) { db <- .build_Rd_db(pkgdir, stages = NULL, os = c("unix", "windows"), step = 1) if (!length(db)) return(FALSE) # Strip the pkgdir off the names names(db) <- substring(names(db), nchar(file.path(pkgdir, "man")) + 2L) containsSexprs <- which(sapply(db, function(Rd) getDynamicFlags(Rd)["\\Sexpr"])) if (!length(containsSexprs)) return(FALSE) messageLog(Log, "installing the package to process help pages") dir.create(libdir, mode = "0755", showWarnings = FALSE) savelib <- .libPaths() .libPaths(c(libdir, savelib)) on.exit(.libPaths(savelib), add = TRUE) temp_install_pkg(pkgdir, libdir) containsBuildSexprs <- which(sapply(db, function(Rd) getDynamicFlags(Rd)["build"])) if (length(containsBuildSexprs)) { for (i in containsBuildSexprs) db[[i]] <- prepare_Rd(db[[i]], stages = "build", stage2 = FALSE, stage3 = FALSE) messageLog(Log, "saving partial Rd database") partial <- db[containsBuildSexprs] dir.create("build", showWarnings = FALSE) saveRDS(partial, file.path("build", "partial.rdb")) } needRefman <- manual && parse_description_field(desc, "BuildManual", TRUE) && any(sapply(db, function(Rd) any(getDynamicFlags(Rd)[c("install", "render")]))) if (needRefman) { messageLog(Log, "building the PDF package manual") dir.create("build", showWarnings = FALSE) refman <- file.path(pkgdir, "build", paste0(basename(pkgdir), ".pdf")) ..Rd2pdf(c("--force", "--no-preview", paste0("--output=", refman), pkgdir), quit = FALSE) } return(TRUE) } ## also fixes up missing final NL fix_nonLF_in_files <- function(pkgname, dirPattern, Log) { if(dir.exists(sDir <- file.path(pkgname, "src"))) { files <- dir(sDir, pattern = dirPattern, full.names = TRUE, recursive = TRUE) ## FIXME: This "destroys" all timestamps for (ff in files) { lines <- readLines(ff, warn = FALSE) writeLinesNL(lines, ff) } } } fix_nonLF_in_source_files <- function(pkgname, Log) { fix_nonLF_in_files(pkgname, dirPattern = "\\.([cfh]|cc|cpp)$", Log) } fix_nonLF_in_make_files <- function(pkgname, Log) { fix_nonLF_in_files(pkgname, paste0("^(", paste(c("Makefile", "Makefile.in", "Makefile.win", "Makevars", "Makevars.in", "Makevars.win"), collapse = "|"), ")$"), Log) ## Other Makefiles makes <- dir(pkgname, pattern = "^Makefile$", full.names = TRUE, recursive = TRUE) for (ff in makes) { lines <- readLines(ff, warn = FALSE) writeLinesNL(lines, ff) } } find_empty_dirs <- function(d) { ## dir(recursive = TRUE) did not include directories, so ## we needed to do this recursively files <- dir(d, all.files = TRUE, full.names = TRUE) for (dd in files[dir.exists(files)]) { if (grepl("/\\.+$", dd)) next find_empty_dirs(dd) } ## allow per-package override keep_empty1 <- parse_description_field(desc, "BuildKeepEmpty", keep_empty) if (!keep_empty1) # might have removed a dir files <- dir(d, all.files = TRUE, full.names = TRUE) if (length(files) <= 2L) { # always has ., .. if (keep_empty1) { printLog(Log, "WARNING: directory ", sQuote(d), " is empty\n") } else { unlink(d, recursive = TRUE) printLog(Log, "Removed empty directory ", sQuote(d), "\n") } } } fixup_R_dep <- function(pkgname, ver = "2.10") { desc <- .read_description(file.path(pkgname, "DESCRIPTION")) Rdeps <- .split_description(desc)$Rdepends2 for(dep in Rdeps) { if(dep$op != '>=') next if(dep$version >= package_version(ver)) return() } on.exit(Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE"))) Sys.setlocale("LC_CTYPE", "C") flatten <- function(x) { if(length(x) == 3L) paste0(x$name, " (", x$op, " ", x$version, ")") else x[[1L]] } deps <- desc["Depends"] desc["Depends"] <- if(!is.na(deps)) { deps <- .split_dependencies(deps) deps <- deps[names(deps) != "R"] # could be more than one paste(c(sprintf("R (>= %s)", ver), sapply(deps, flatten)), collapse = ", ") } else sprintf("R (>= %s)", ver) .write_description(desc, file.path(pkgname, "DESCRIPTION")) printLog(Log, " NB: this package now depends on R (>= ", ver, ")\n") } resave_data_rda <- function(pkgname, resave_data) { if (resave_data == "no") return() ddir <- file.path(pkgname, "data") if(resave_data == "best") { files <- Sys.glob(c(file.path(ddir, "*.rda"), file.path(ddir, "*.RData"), file.path(pkgname, "R", "sysdata.rda"))) messageLog(Log, "re-saving image files") resaveRdaFiles(files) rdas <- checkRdaFiles(files) if(any(rdas$compress %in% c("bzip2", "xz"))) fixup_R_dep(pkgname, "2.10") } else { ## ddir need not exist if just R/sysdata.rda rdas <- checkRdaFiles(Sys.glob(c(file.path(ddir, "*.rda"), file.path(ddir, "*.RData")))) if(nrow(rdas)) { update <- with(rdas, ASCII | compress == "none" | version < 2) if(any(update)) { messageLog(Log, "re-saving image files") resaveRdaFiles(row.names(rdas)[update], "gzip") } } if(file.exists(f <- file.path(pkgname, "R", "sysdata.rda"))) { rdas <- checkRdaFiles(f) update <- with(rdas, ASCII | compress == "none" | version < 2) if(any(update)) { messageLog(Log, "re-saving sysdata.rda") resaveRdaFiles(f, "gzip") } } } } resave_data_others <- function(pkgname, resave_data) { if (resave_data == "no") return() ddir <- file.path(pkgname, "data") dataFiles <- grep("\\.(rda|RData)$", list_files_with_type(ddir, "data"), invert = TRUE, value = TRUE) if (!length(dataFiles)) return() Rs <- grep("\\.[Rr]$", dataFiles, value = TRUE) if (length(Rs)) { # these might use .txt etc messageLog(Log, "re-saving .R files as .rda") ## ensure utils is visible library("utils") lapply(Rs, function(x){ envir <- new.env(hash = TRUE) sys.source(x, chdir = TRUE, envir = envir) save(list = ls(envir, all.names = TRUE), file = sub("\\.[Rr]$", ".rda", x), compress = TRUE, compression_level = 9, envir = envir) unlink(x) }) printLog(Log, " NB: *.R converted to .rda: other files may need to be removed\n") } tabs <- grep("\\.(CSV|csv|TXT|tab|txt)$", dataFiles, value = TRUE) if (length(tabs)) { messageLog(Log, "re-saving tabular files") if (resave_data == "gzip") { lapply(tabs, function(nm) { ## DiceDesign/data/greenwood.table.txt is missing NL x <- readLines(nm, warn = FALSE) con <- gzfile(paste(nm, "gz", sep = "."), "wb") writeLines(x, con) close(con) unlink(nm) }) } else { OK <- TRUE lapply(tabs, function(nm) { x <- readLines(nm, warn = FALSE) nm3 <- paste(nm, c("gz", "bz2", "xz"), sep = ".") con <- gzfile(nm3[1L], "wb", compression = 9L); writeLines(x, con); close(con) con <- bzfile(nm3[2L], "wb", compression = 9L); writeLines(x, con); close(con) con <- xzfile(nm3[3L], "wb", compression = 9L); writeLines(x, con); close(con) sizes <- file.size(nm3) * c(0.9, 1, 1) ind <- which.min(sizes) if(ind > 1) OK <<- FALSE unlink(c(nm, nm3[-ind])) }) if (!OK) fixup_R_dep(pkgname, "2.10") } } } force <- FALSE vignettes <- TRUE manual <- TRUE # Install the manual if Rds contain \Sexprs with_md5 <- FALSE ## INSTALL_opts <- character() pkgs <- character() options(showErrorCalls = FALSE, warn = 1) ## Read in build environment file. Renv <- Sys.getenv("R_BUILD_ENVIRON", unset = NA) if(!is.na(Renv)) { ## Do not read any build environment file if R_BUILD_ENVIRON is ## set to empty of something non-existent. if(nzchar(Renv) && file.exists(Renv)) readRenviron(Renv) } else { ## Read in ~/.R/build.Renviron[.rarch] (if existent). rarch <- .Platform$r_arch if (nzchar(rarch) && file.exists(Renv <- paste("~/.R/build.Renviron", rarch, sep = "."))) readRenviron(Renv) else if (file.exists(Renv <- "~/.R/build.Renviron")) readRenviron(Renv) } ## Configurable variables. compact_vignettes <- Sys.getenv("_R_BUILD_COMPACT_VIGNETTES_", "no") resave_data <- Sys.getenv("_R_BUILD_RESAVE_DATA_", "gzip") keep_empty <- config_val_to_logical(Sys.getenv("_R_BUILD_KEEP_EMPTY_DIRS_", "FALSE")) if (is.null(args)) { args <- commandArgs(TRUE) ## it seems that splits on spaces, so try harder. args <- paste(args, collapse = " ") args <- strsplit(args,'nextArg', fixed = TRUE)[[1L]][-1L] } while(length(args)) { a <- args[1L] if (a %in% c("-h", "--help")) { Usage() do_exit(0L) } else if (a %in% c("-v", "--version")) { cat("R add-on package builder: ", R.version[["major"]], ".", R.version[["minor"]], " (r", R.version[["svn rev"]], ")\n", sep = "") cat("", "Copyright (C) 1997-2013 The R Core Team.", "This is free software; see the GNU General Public License version 2", "or later for copying conditions. There is NO warranty.", sep = "\n") do_exit(0L) } else if (a == "--force") { force <- TRUE } else if (a == "--keep-empty-dirs") { keep_empty <- TRUE } else if (a == "--no-build-vignettes") { vignettes <- FALSE } else if (a == "--no-vignettes") { # pre-3.0.0 version stop("'--no-vignettes' is defunct:\n use '--no-build-vignettes' instead", call. = FALSE, domain = NA) } else if (a == "--resave-data") { resave_data <- "best" } else if (a == "--no-resave-data") { resave_data <- "no" } else if (substr(a, 1, 14) == "--resave-data=") { resave_data <- substr(a, 15, 1000) } else if (a == "--no-manual") { manual <- FALSE } else if (substr(a, 1, 20) == "--compact-vignettes=") { compact_vignettes <- substr(a, 21, 1000) } else if (a == "--compact-vignettes") { compact_vignettes <- "qpdf" } else if (a == "--md5") { with_md5 <- TRUE } else if (substr(a, 1, 1) == "-") { message("Warning: unknown option ", sQuote(a)) } else pkgs <- c(pkgs, a) args <- args[-1L] } if(!compact_vignettes %in% c("no", "qpdf", "gs", "gs+qpdf", "both")) { warning(gettextf("invalid value for '--compact-vignettes', assuming %s", "\"qpdf\""), domain = NA) compact_vignettes <-"qpdf" } Sys.unsetenv("R_DEFAULT_PACKAGES") startdir <- getwd() if (is.null(startdir)) stop("current working directory cannot be ascertained") ## R_platform <- Sys.getenv("R_PLATFORM", "unknown-binary") ## libdir <- tempfile("Rinst") if (WINDOWS) { ## Some people have *assumed* that R_HOME uses / in Makefiles ## Spaces in paths might still cause trouble. rhome <- chartr("\\", "/", R.home()) Sys.setenv(R_HOME = rhome) } for(pkg in pkgs) { Log <- newLog() # if not stdin; on.exit(closeLog(Log)) ## remove any trailing /, for Windows' sake pkg <- sub("/$", "", pkg) ## 'Older versions used $pkg as absolute or relative to $startdir. ## This does not easily work if $pkg is a symbolic link. ## Hence, we now convert to absolute paths.' setwd(startdir) res <- tryCatch(setwd(pkg), error = function(e)e) if (inherits(res, "error")) { errorLog(Log, "cannot change to directory ", sQuote(pkg)) do_exit(1L) } pkgdir <- getwd() pkgname <- basename(pkgdir) checkingLog(Log, "for file ", sQuote(file.path(pkg, "DESCRIPTION"))) f <- file.path(pkgdir, "DESCRIPTION") if (file.exists(f)) { desc <- try(.read_description(f)) if (inherits(desc, "try-error") || !length(desc)) { resultLog(Log, "EXISTS but not correct format") do_exit(1L) } resultLog(Log, "OK") } else { resultLog(Log, "NO") do_exit(1L) } intname <- desc["Package"] ## make a copy, cd to parent of copy setwd(dirname(pkgdir)) filename <- paste0(intname, "_", desc["Version"], ".tar") filepath <- file.path(startdir, filename) Tdir <- tempfile("Rbuild") dir.create(Tdir, mode = "0755") if (WINDOWS) { ## This preserves read-only for files, but not dates if (!file.copy(pkgname, Tdir, recursive = TRUE)) { errorLog(Log, "copying to build directory failed") do_exit(1L) } } else { ## This should preserve dates and permissions (subject to ## umask, if that is consulted which it seems it usually is not). ## Permissions are increased later. cp_sw <- if(Sys.info()[["sysname"]] == "Linux") ## << need GNU cp ## unfortunately, '-pr' does not dereference sym.links "-Lr --preserve=timestamps" else "-pr" if (system(paste("cp", cp_sw, shQuote(pkgname), shQuote(Tdir)))) { errorLog(Log, "copying to build directory failed") do_exit(1L) } } setwd(Tdir) ## Now correct the package name (PR#9266) if (pkgname != intname) { if (!file.rename(pkgname, intname)) { message(gettextf("Error: cannot rename directory to %s", sQuote(intname)), domain = NA) do_exit(1L) } pkgname <- intname } ## prepare the copy messageLog(Log, "preparing ", sQuote(pkgname), ":") prepare_pkg(normalizePath(pkgname, "/"), desc, Log); owd <- setwd(pkgname) ## remove exclude files allfiles <- dir(".", all.files = TRUE, recursive = TRUE, full.names = TRUE, include.dirs = TRUE) allfiles <- substring(allfiles, 3L) # drop './' bases <- basename(allfiles) exclude <- rep(FALSE, length(allfiles)) ignore <- get_exclude_patterns() ## handle .Rbuildignore: ## 'These patterns should be Perl regexps, one per line, ## to be matched against the file names relative to ## the top-level source directory.' ignore_file <- file.path(pkgdir, ".Rbuildignore") if (file.exists(ignore_file)) ignore <- c(ignore, readLines(ignore_file, warn = FALSE)) for(e in ignore[nzchar(ignore)]) exclude <- exclude | grepl(e, allfiles, perl = TRUE, ignore.case = TRUE) isdir <- dir.exists(allfiles) ## old (pre-2.10.0) dirnames exclude <- exclude | (isdir & (bases %in% c("check", "chm", .vc_dir_names))) exclude <- exclude | (isdir & grepl("([Oo]ld|\\.Rcheck)$", bases)) ## FIXME: GNU make uses GNUmakefile (note capitalization) exclude <- exclude | bases %in% c("Read-and-delete-me", "GNUMakefile") ## Mac resource forks exclude <- exclude | grepl("^\\._", bases) exclude <- exclude | (isdir & grepl("^src.*/[.]deps$", allfiles)) ## Windows DLL resource file exclude <- exclude | (allfiles == paste0("src/", pkgname, "_res.rc")) ## inst/doc/.Rinstignore is a mistake exclude <- exclude | grepl("inst/doc/[.](Rinstignore|build[.]timestamp)$", allfiles) exclude <- exclude | grepl("vignettes/[.]Rinstignore$", allfiles) ## leftovers exclude <- exclude | grepl("^.Rbuildindex[.]", allfiles) exclude <- exclude | (bases %in% .hidden_file_exclusions) unlink(allfiles[exclude], recursive = TRUE, force = TRUE) setwd(owd) ## Fix up man, R, demo inst/doc directories res <- .check_package_subdirs(pkgname, TRUE) if (any(lengths(res))) { messageLog(Log, "excluding invalid files") print(res) # FIXME print to Log? } setwd(Tdir) ## Fix permissions for all files to be at least 644, and dirs 755 ## Not restricted by umask. if (!WINDOWS) .Call(dirchmod, pkgname, group.writable=FALSE) ## Add build stamp to the DESCRIPTION file. add_build_stamp_to_description_file(file.path(pkgname, "DESCRIPTION"), pkgdir) ## Add expanded R fields to the DESCRIPTION file. add_expanded_R_fields_to_description_file(file.path(pkgname, "DESCRIPTION")) messageLog(Log, "checking for LF line-endings in source and make files") fix_nonLF_in_source_files(pkgname, Log) fix_nonLF_in_make_files(pkgname, Log) messageLog(Log, "checking for empty or unneeded directories"); find_empty_dirs(pkgname) for(dir in c("Meta", "R-ex", "chtml", "help", "html", "latex")) { d <- file.path(pkgname, dir) if (dir.exists(d)) { msg <- paste("WARNING: Removing directory", sQuote(d), "which should only occur", "in an installed package") printLog(Log, paste(strwrap(msg, indent = 0L, exdent = 2L), collapse = "\n"), "\n") unlink(d, recursive = TRUE) } } ## remove subarch build directories unlink(file.path(pkgname, c("src-i386", "src-x64", "src-x86_64", "src-ppc")), recursive = TRUE) ## work on 'data' directory if present if(dir.exists(file.path(pkgname, "data")) || file_test("-f", file.path(pkgname, "R", "sysdata.rda"))) { messageLog(Log, "looking to see if a 'data/datalist' file should be added") ## in some cases data() needs the package installed as ## there are links to the package's namespace tryCatch(add_datalist(pkgname), error = function(e) printLog(Log, " unable to create a 'datalist' file: may need the package to be installed\n")) ## allow per-package override resave_data1 <- parse_description_field(desc, "BuildResaveData", resave_data, FALSE) resave_data_others(pkgname, resave_data1) resave_data_rda(pkgname, resave_data1) } ## add NAMESPACE if the author didn't write one if(!file.exists(namespace <- file.path(pkgname, "NAMESPACE")) ) { messageLog(Log, "creating default NAMESPACE file") writeDefaultNamespace(namespace) } if(with_md5) { messageLog(Log, "adding MD5 file") .installMD5sums(pkgname) } else { ## remove any stale file unlink(file.path(pkgname, "MD5")) } ## Finalize filename <- paste0(pkgname, "_", desc["Version"], ".tar.gz") filepath <- file.path(startdir, filename) ## NB: tests/reg-packages.R relies on this exact format! messageLog(Log, "building ", sQuote(filename)) res <- utils::tar(filepath, pkgname, compression = "gzip", compression_level = 9L, tar = Sys.getenv("R_BUILD_TAR"), extra_flags = NULL) # use trapdoor if (res) { errorLog(Log, "packaging into .tar.gz failed") do_exit(1L) } message("") # blank line setwd(startdir) unlink(Tdir, recursive = TRUE) on.exit() # cancel closeLog closeLog(Log) } do_exit(0L) }
42,369
gpl-2.0
aaa3540934ff4961c8e051b3fea8d36704d1e40d
kalden/spartan
tests/testthat/test_efast_sampling_netlogo.R
library(spartan) library(XML) context("Test of Spartan Netlogo eFAST Sampling") test_that("efast_generate_sample_netlogo", { skip_on_cran() # Generate the samples, then we'll check the content # eFAST sampling has been tested independently, within that method efast_generate_sample_netlogo( FILEPATH=getwd(), 3, 65, c("death-thru-sickness","death-but-immune","death-old-age","death-old-and-sick"), c("people","infectiousness","dummy"), c(150,"[10,90]","[1,10]"), 1,"true","setup","go") # Test the sample files have been generated expect_true(file.exists(paste(getwd(),"/Curve1_infectiousness.csv",sep=""))) expect_true(file.exists(paste(getwd(),"/Curve1_dummy.csv",sep=""))) # Now we can check the content of a random file xml_doc <- read_created_efast_xml_file() # Now compare the results expect_equal(xml_doc$xml_param_vals,xml_doc$sampled_vals) expect_equal(xml_doc$measures,c("death-thru-sickness","death-but-immune","death-old-age", "death-old-and-sick")) expect_equal(xml_doc$setup,"setup") expect_equal(xml_doc$go,"go") expect_equal(xml_doc$people,150) rm(xml_doc) # Remove the created files file.remove(file.path(getwd(),"Curve1_infectiousness.csv")) file.remove(file.path(getwd(),"Curve2_infectiousness.csv")) file.remove(file.path(getwd(),"Curve3_infectiousness.csv")) #file.remove(paste(getwd(),"/Curve1_duration.csv",sep="")) #file.remove(paste(getwd(),"/Curve2_duration.csv",sep="")) #file.remove(paste(getwd(),"/Curve3_duration.csv",sep="")) file.remove(file.path(getwd(),"Curve1_dummy.csv")) file.remove(file.path(getwd(),"Curve2_dummy.csv")) file.remove(file.path(getwd(),"Curve3_dummy.csv")) #file.remove(paste(getwd(),"/Curve1_chance-recover.csv",sep="")) #file.remove(paste(getwd(),"/Curve2_chance-recover.csv",sep="")) #file.remove(paste(getwd(),"/Curve3_chance-recover.csv",sep="")) unlink(file.path(getwd(),"1"), recursive = TRUE) unlink(file.path(getwd(),"2"), recursive = TRUE) unlink(file.path(getwd(),"3"), recursive = TRUE) })
2,077
gpl-2.0
72eda255b2d387e0d7a5d274a46bf67af238b32e
geiser/2017-experiment-analysis
study03/03-irt-correlation-signedup-analysis.R
library(psych) library(readr) library(dplyr) library(readxl) library(PerformanceAnalytics) participants <- read_csv('data/SignedUpParticipants.csv') info_src <- list( "gain.theta" = list( sheed = "data", dv = "gain.theta", wid = "UserID" , dv.name = "Gains in Skill/Knowledge" , filename = "report/learning-outcomes/signedup-participants/ParametricAnalysis.xlsx") , "IntrinsicMotivation" = list( sheed = "data", dv = "Intrinsic Motivation", wid = "UserID" , filename = "report/motivation/signedup-participants/intrinsic-motivation/by-Type/ParametricAnalysis.xlsx") , "InterestEnjoyment" = list( sheed = "data", dv = "Interest/Enjoyment", wid = "UserID" , filename = "report/motivation/signedup-participants/interest-enjoyment/by-Type/ParametricAnalysis.xlsx") , "PerceivedChoice" = list( sheed = "data", dv = "Perceived Choice", wid = "UserID" , filename = "report/motivation/signedup-participants/perceived-choice/by-Type/ParametricAnalysis.xlsx") , "PressureTension" = list( sheed = "data", dv = "Pressure/Tension", wid = "UserID" , filename = "report/motivation/signedup-participants/pressure-tension/by-Type/ParametricAnalysis.xlsx") , "EffortImportance" = list( sheed = "data", dv = "Effort/Importance", wid = "UserID" , filename = "report/motivation/signedup-participants/effort-importance/by-Type/ParametricAnalysis.xlsx") , "LevelofMotivation" = list( sheed = "data", dv = "Level of Motivation", wid = "UserID" , filename = "report/motivation/signedup-participants/level-of-motivation/by-Type/ParametricAnalysis.xlsx") , "Attention" = list( sheed = "data", dv = "Attention", wid = "UserID" , filename = "report/motivation/signedup-participants/attention/by-Type/ParametricAnalysis.xlsx") , "Relevance" = list( sheed = "data", dv = "Relevance", wid = "UserID" , filename = "report/motivation/signedup-participants/relevance/by-Type/ParametricAnalysis.xlsx") , "Satisfaction" = list( sheed = "data", dv = "Satisfaction", wid = "UserID" , filename = "report/motivation/signedup-participants/satisfaction/by-Type/ParametricAnalysis.xlsx") ) corr_pair_mods <- get_corr_pair_mods( participants, iv = "Type", wid = "UserID", between = c('Type', 'CLRole') , corr_var = list( dv1=c('gain.theta') , dv2=c('IntrinsicMotivation', 'InterestEnjoyment' , 'PerceivedChoice', 'PressureTension', 'EffortImportance' , 'LevelofMotivation', 'Attention', 'Relevance', 'Satisfaction') ) , info_src = info_src , include.subs = TRUE , method = "spearman" ) corr_matrix_mods <- get_corr_matrix_mods( participants, corr_pair_mods , dvs = list( "Gains in Skill/Knowledge and Motivation" = c( 'Gains in Skill/Knowledge' , 'Intrinsic Motivation' , 'Interest/Enjoyment', 'Perceived Choice', 'Pressure/Tension', 'Effort/Importance' , 'Level of Motivation' , 'Attention', 'Relevance', 'Satisfaction') ) , wid = "UserID" , method = "spearman" ) ## Write report write_corr_matrix_report( corr_matrix_mods , filename = "report/correlation/signedup-participants/CorrMatrixAnalysis.xlsx" , override = TRUE ) write_corr_pair_report( corr_pair_mods , path = "report/correlation/signedup-participants/" , override = TRUE ) ## Write plots write_corr_matrix_plots( corr_matrix_mods , path = "report/correlation/signedup-participants/corr-matrix-plots/" , override = TRUE ) write_corr_chart_plots( corr_pair_mods , path = "report/correlation/signedup-participants/corr-chart-plots/" , override = TRUE ) write_scatter_plots( corr_pair_mods , path = "report/correlation/signedup-participants/corr-scatter-plots/" , override = TRUE ) ############################################################################# ## Translate latex resume ## ############################################################################# write_summary_corr_matrix_mods_in_latex( corr_matrix_mods , filename = paste0("report/latex/correlation-signedup-analysis.tex") , in_title = paste0("between motivation factors and in the third empirical study") )
4,189
gpl-3.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
krlmlr/cxxr
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
kmillar/rho
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
cxxr-devel/cxxr
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
ArunChauhan/cxxr
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
kmillar/cxxr
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
fbaf9a22ca6e7673f4a233a06e141bdeb2f0bfa4
rho-devel/rho
src/extra/testr/filtered-test-suite/operators/tc_operators_207.R
expected <- eval(parse(text="c(4.5241870901798, 0.211646098116025, 1.86003798801034e-43)")); test(id=0, code={ argv <- eval(parse(text="list(5, c(0.90483741803596, 0.042329219623205, 3.72007597602068e-44))")); do.call(`*`, argv); }, o=expected);
272
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
kalibera/rexp
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
rho-devel/rho
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
0aa025e7406007f069f8b1532c48bc5ec9e2067e
igm-team/meaRtools
meaRtools/inst/sje1.R
## sje testing functions. require(devtools) load_all() require(sjemea) require(lattice) options(sjemea.corr.method = "Tiling") options(sjemea.corr.dt = 0.05) #default 50ms. ## check network spikes data.file <- system.file("examples", "TC89_DIV15_A.nexTimestamps", package = "sjemea") s <- sanger.read.spikes( data.file, beg=400, end=700) ns1 <- sjemea::compute.ns(s, ns.T=0.003, ns.N=10,sur=100) ns2 <- .compute_ns(s, ns_t=0.003, ns_n=10,sur=100) plot(ns1) plot_network_spikes(ns2) ## Note problem: this should be just plot(ns2) colnames(ns1$measures) <- NULL colnames(ns2$measures) <- NULL all.equal(ns1, ns2, check.names = FALSE) ## TODO plot_network_spikes is the wrong function name, it should be plot.ns() as this is the ## S3 plot() class for the "ns" type. ## check STTC t1 <- sjemea::tiling.allpairwise(s) levelplot(t1) t2 <- sttc_allspikes1(s$spikes, dt=getOption("sjemea.corr.dt"), s$rec.time[1], s$rec.time[2]) all.equal(t1, t2) ## NB: I need to check how to easily convert rec.time to rec_time everywhere. ## check correlation index ## NOT YET FIXED!!! .make.corr.indexes2 will not work! ## check firing rate r1 = sjemea::make.spikes.to.frate(s$spikes) r2 = .make_spikes_to_frate(s$spikes) all.equal(r1,r2) # see issue about the inequality changing in the above function. ## Check the plot function data(S) S1 = list(S=S) plot_plate_summary_for_spikes(S1, "/tmp") demas_platelayout = list(n_well = 6, wells = paste0("w", "1:6"), n_well_r = 2, n_well_c = 3, layout = c(3, 2), n_elec_r = 8, n_elec_c = 8, xlim = c(-100, 7200), ylim = c(0, 6000), spacing = 200, corr_breaks = 0 ) add_plateinfo("demas-6well", demas_platelayout) times = system.file("extdata/textreader/demas.times", package="meaRtools") pos = system.file("extdata/textreader/demas.pos", package="meaRtools") s = read_spikelist_text(times, pos, array="demas-6well") .plot_mealayout(s$layout, use_names = TRUE, cex=0.3) ## two problems - w_ch_00 ==> channel name should be ch_00 ## position of plots. .plot_meanfiringrate(s, main = "Mean Firing Rate by Plate (Hz)") ## next: work through next plot_plate_summary_for_spikes .channel_plot_by_well(s, resp = "meanfiringrate", resp_label = "Mean Firing Rate (Hz)") ## Sahar: are ISIs not added by default? s <- calculate_isis(s) .plot_isis_by_plate(s) .plot_isis_by_electrode(s) ## does nothing? ## what is the s$cw field? wells that are okay? s = get_num_ae(s) .channel_plot_by_well(s, resp = "meanfiringrate", resp_label = "Mean Firing Rate (Hz)") .plot_mean_firingrate_by_electrode(S) .plot_mean_firingrate_by_electrode(s)
2,964
gpl-3.0
488490735aebfffc2c59ccb44befaffa22ac23de
jeroenooms/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
aviralg/R-dyntrace
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
kmillar/rho
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
cmosetick/RRO
R-src/src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
skyguy94/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
cxxr-devel/cxxr
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
hadley/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
ArunChauhan/cxxr
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
reactorlabs/gnur
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
mathematicalcoffee/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
WelkinGuan/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
bedatadriven/renjin
packages/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
MouseGenomics/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
SurajGupta/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
graalvm/fastr
com.oracle.truffle.r.native/gnur/patch/src/library/grid/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
wch/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
mirror/r
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
jimhester/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
jeffreyhorner/R-Judy-Arrays
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
lajus/customr
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
limeng12/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
minux/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
kmillar/cxxr
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
o-/Rexperiments
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
LeifAndersen/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
jeffreyhorner/R-Array-Hash
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
andy-thomason/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
jagdeesh109/RRO
R-src/src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
glycerine/bigbird
r-3.0.2/src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
bsd-2-clause
488490735aebfffc2c59ccb44befaffa22ac23de
allr/r-instrumented
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
SensePlatform/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
RevolutionAnalytics/RRO
R-src/src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
abiyug/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
hxfeng/R-3.1.2
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
ChiWang/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
patperry/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
nathan-russell/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
allr/timeR
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
krlmlr/cxxr
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
cxxr-devel/cxxr-svn-mirror
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
krlmlr/r-source
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
488490735aebfffc2c59ccb44befaffa22ac23de
Mouseomics/R
src/library/grid/R/metric.R
# API to access detailed text metric info # # Copyright (C) 1995-2012 The R Core Team # This first function does NOT return a "unit" object # It is just access to font metric info in the calling context # (similar to the convert*() functions, with corresponding caveats on use) grid.textMetric <- function(string) { } # It should be possible to define units like "strascent" and "strdescent"
398
gpl-2.0
29bd323d16e3616090bdd95a5aeb7ddb57939581
pdp10/pip3_mirna
7_miRNA_timecourses/miRNA_timecourses.R
# The MIT License # # Copyright (c) 2017 Piero Dalle Pezze # # Permission is hereby granted, free of charge, # to any person obtaining a copy of this software and # associated documentation files (the "Software"), to # deal in the Software without restriction, including # without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom # the Software is furnished to do so, # subject to the following conditions: # # The above copyright notice and this permission notice # shall be included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. print('mean_norm_miRNA_expr_tc') source('mean_norm_miRNA_expr_tc.R') rm(list = ls()) print('deseq2_tc_lfc') source('deseq2_tc_lfc.R') rm(list = ls()) print('counts_matrix_heatplot') source('counts_matrix_heatplot.R') rm(list = ls())
1,383
mit
1fd65e60449d7f93f6402dae6aa1f392c15f2d8d
physion/ovation-R
Rovation/R/ovation_testing.R
#' Creates a new Ovation database stack for testing #' #' A testing stack creates a complete, isolated Ovation database and in-memory "cloud" storage provider. #' A local stack should be used for testing only, and should be cleaned up with \code{localStack$cleanUp} when #' done. #' #' @return new us.physion.ovation.test.util.TestUtils instance #' @param name database name #' @export NewLocalStack <- function(name) { test.utils <- new(J("us.physion.ovation.test.util.TestUtils")) local.stack <- test.utils$makeLocalStack(new(J("us.physion.ovation.api.OvationApiModule")), name, name, name) return(local.stack) } #' Wrapps a callable in a LocalStack #' #' The test function should take a \code{DataContext} as its only parameter. It will be passed #' an authenticated \code{DataContext} for the local stack. The local stack is automatically #' cleaned up after the function exits. #' #' @param name database name #' @param test.fn test callable #' @export TestWrapper <- function(name, test.fn) { stack <- NewLocalStack(name) tryCatch(test.fn(stack$getAuthenticatedDataStoreCoordinator()$getContext()), finally=stack$cleanUp()) }
1,291
bsd-2-clause
35e11d25972357a0f94e912280b4936ff11b514c
bedatadriven/renjin
tests/src/test/R/test.qr.R
# # Renjin : JVM-based interpreter for the R language for the statistical analysis # Copyright © 2010-2019 BeDataDriven Groep B.V. and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, a copy is available at # https://www.gnu.org/licenses/gpl-2.0.txt # test.qr <- function() { hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") } h3 <- hilbert(3) print(qr(h3)) }
951
gpl-2.0