-
Notifications
You must be signed in to change notification settings - Fork 0
/
baby_steps.R
145 lines (117 loc) · 3.82 KB
/
baby_steps.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
############################################################
# A simple function to connect to a DataSHIELD VM server
# and test functions
# (written for both the client and the server)
############################################################
####################
# Load library
####################
#library(ggplot2)
#library(opal)
#library(dsBaseClient)
## update.packages(repos='http://cran.obiba.org')
#library(opal)
#library(dsBaseClient)
#library(dsStatsClient)
#library(dsGraphicsClient)
#library(dsModellingClient)
require('DSI')
require('DSOpal')
require('dsBaseClient')
#######################
# Get data
#######################
builder <- DSI::newDSLoginBuilder()
builder$append(server = "study1",
url = "http://192.168.56.100:8080/",
user = "administrator", password = "datashield_test&",
table = "SURVIVAL.EXPAND_NO_MISSING1", driver = "OpalDriver")
builder$append(server = "study2",
url = "http://192.168.56.100:8080/",
user = "administrator", password = "datashield_test&",
table = "SURVIVAL.EXPAND_NO_MISSING2", driver = "OpalDriver")
#builder$append(server = "study3",
# url = "http://192.168.56.100:8080/",
# user = "administrator", password = "datashield_test&",
# table = "SURVIVAL.EXPAND_NO_MISSING3", driver = "OpalDriver")
logindata <- builder$build()
##############
# login
##############
# opals <- datashield.login(logins=logindata,assign=TRUE)
# Log onto the remote Opal training servers
connections <- DSI::datashield.login(logins = logindata, assign = TRUE, symbol = "D")
# source('~/DSI/R/datashield.login.R')
# connections <- datashield.login(logins = logindata, assign = TRUE, symbol = "D")
# make sure that the outcome is numeric
ds.asNumeric(x.name = "D$cens",
newobj = "EVENT",
datasources = connections)
# convert time id variable to a factor
ds.asFactor(input.var.name = "D$time.id",
newobj = "TID",
datasources = connections)
# create in the server-side the log(survtime) variable
ds.log(x = "D$survtime",
newobj = "log.surv",
datasources = connections)
# check whcih variables exist
ds.ls()
out_coeff_model <- ds.glmSLMA(formula = EVENT ~ 1 + TID + female * age.60,
data = "D",
family = "poisson",
offset = "log.surv",
weights = NULL,
checks = FALSE,
maxit = 20,
datasources = connections)
data# TODO: get coefficients
# call new function modofy NAMESPACE and DESCRIPTION
# client function in
# https://github.com/neelsoumya/dsBaseClient/blob/absolute_newbie_client/R/ds.retStr.R
# server function in
# https://github.com/neelsoumya/dsBase/blob/absolute_newbie/R/retStrDS.R
source('~/soumya_mrc/dsBaseClient/R/ds.retStr.R')
ds.retStr("thisisastringfromclient")
cat(datashield.errors())
print(datashield.errors())
#ds.ls()
# TESTING
# must be string with no spaces
ds.retStr('shortstring')
ds.retStr('123')
ds.retStr('$')
retval_try = try( ( ds.retStr('1=1') ) ,
silent = TRUE
)
if ( inherits(retval_try, 'error') )
{
cat("\n Command failed test \n")
}
retval_try = try ( ( ds.retStr('1+1=2') ),
silent = TRUE
)
if ( inherits(retval_try, 'error') )
{
cat("\n Command failed test \n")
}
retval_try = try ( ( ds.retStr(' ') ),
silent = TRUE
)
if ( inherits(retval_try, 'error') )
{
cat("\n Command failed test \n")
}
retval_try = try ( ( ds.retStr('@fg67') ),
silent = TRUE
)
if ( inherits(retval_try, 'error') )
{
cat("\n Command failed test \n")
}
# disconnect
cat("\n Disconnecting ... \n")
#DSI::datashield.logout(conn=connections)
# clean up
#rm()
#gc()