sstat 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/sstat/lib/survival/survival_kaplan_meier.h +18 -5
- data/ext/sstat/sstat.o +0 -0
- data/ext/sstat/sstat.so +0 -0
- data/lib/sstat.so +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84e0e83a5a7938320e490283d07ff2bf7039d980
|
|
4
|
+
data.tar.gz: 072d1a1b15b07feadfa0b4364fe5eb56f2da4ae8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f81a5fda02ce1e2e12adf4b66dee88df6ae452daec9f3b37062c6353d112e02c8c3be3361e5f5b272068d8f94b3361ed2870408331cdb366e4ac6185d6fb361
|
|
7
|
+
data.tar.gz: 757041cda1d6ae40a790138792e8cab507b9d60d9edf8c5b6451c9b115f73503ddef08c255776254377893e82d84e396382f09465761dd53843b2bbb6796c644
|
|
@@ -12,6 +12,17 @@
|
|
|
12
12
|
* @return CENS_UC_NUM structure
|
|
13
13
|
*/
|
|
14
14
|
#define EXP 1e-12
|
|
15
|
+
|
|
16
|
+
double max_time_point(double* time, int size) {
|
|
17
|
+
double max = 0;
|
|
18
|
+
for(int i = 0; i < size; i++) {
|
|
19
|
+
if(time[i] > max)
|
|
20
|
+
max = time[i];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return max;
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
int censored_uncensred_each_time_range(double* time, int* censored, int size, struct CENS_UC_NUM** cens_ucens_number)
|
|
16
27
|
{
|
|
17
28
|
int i, count_at, uncensored_num_at, censored_num_at;
|
|
@@ -32,7 +43,6 @@ int censored_uncensred_each_time_range(double* time, int* censored, int size, s
|
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
qsort(time_censored_array, size, sizeof(struct point), &point_compare_x);
|
|
35
|
-
//print_points(time_censored_array, size);
|
|
36
46
|
|
|
37
47
|
/* count number of unique uncensored time point */
|
|
38
48
|
int count = 0;
|
|
@@ -194,7 +204,7 @@ int kaplan_meier(double* time, int* censored, int size, curve* KM_curve)
|
|
|
194
204
|
/**
|
|
195
205
|
* @brief extend the KM curve based on the last 3 points
|
|
196
206
|
*/
|
|
197
|
-
int KM_3p_extrapolation(struct CENS_UC_NUM** cens_uc_num, struct CENS_UC_NUM ** updated_cens_uc_num, int sample_size)
|
|
207
|
+
int KM_3p_extrapolation(struct CENS_UC_NUM** cens_uc_num, struct CENS_UC_NUM ** updated_cens_uc_num, int sample_size, double max_time_point)
|
|
198
208
|
{
|
|
199
209
|
int mean_last_uncensored = 0;
|
|
200
210
|
int mean_last_censored = 0;
|
|
@@ -213,6 +223,7 @@ int KM_3p_extrapolation(struct CENS_UC_NUM** cens_uc_num, struct CENS_UC_NUM **
|
|
|
213
223
|
int extrapolation_size = 0;
|
|
214
224
|
int updated_cens_uc_num_size = 0;
|
|
215
225
|
int i;
|
|
226
|
+
int last_index = (*cens_uc_num)->size - 1;
|
|
216
227
|
int last_1_index = (*cens_uc_num)->size - 2;
|
|
217
228
|
int last_4_index = (*cens_uc_num)->size - 5;
|
|
218
229
|
int actual_updated_size = 0;
|
|
@@ -300,8 +311,6 @@ int KM_3p_extrapolation(struct CENS_UC_NUM** cens_uc_num, struct CENS_UC_NUM **
|
|
|
300
311
|
}
|
|
301
312
|
}
|
|
302
313
|
|
|
303
|
-
//printf("Actual size, number left: %i, %i %i, %i, \n", count, num_left, mean_last_uncensored, mean_last_censored);
|
|
304
|
-
|
|
305
314
|
actual_updated_size = (*cens_uc_num)->size + count;
|
|
306
315
|
|
|
307
316
|
check(alloc_CENS_UC_NUM(updated_cens_uc_num, actual_updated_size) == 0, "Failed in allocating CENS_UC_NUM structure");
|
|
@@ -314,6 +323,9 @@ int KM_3p_extrapolation(struct CENS_UC_NUM** cens_uc_num, struct CENS_UC_NUM **
|
|
|
314
323
|
(*updated_cens_uc_num)->time[i] = (*cens_uc_num)->time[i];
|
|
315
324
|
}
|
|
316
325
|
|
|
326
|
+
time_interval_mean = (max_time_point - (*cens_uc_num)->time[last_index]) / count;
|
|
327
|
+
printf("Time interval: %f \n", time_interval_mean);
|
|
328
|
+
|
|
317
329
|
for(i = (*cens_uc_num)->size; i < actual_updated_size; i++) {
|
|
318
330
|
(*updated_cens_uc_num)->time[i] = (*updated_cens_uc_num)->time[i-1] + time_interval_mean;
|
|
319
331
|
if(i == actual_updated_size -1) {
|
|
@@ -346,6 +358,7 @@ int kaplan_meier_3p_extrapolation(double* time, int* censored, int size, struct
|
|
|
346
358
|
{
|
|
347
359
|
int proc_state = 0;
|
|
348
360
|
struct CENS_UC_NUM* cens_ucens_number;
|
|
361
|
+
double max_time = max_time_point(time, size);
|
|
349
362
|
proc_state = censored_uncensred_each_time_range(time, censored, size, &cens_ucens_number);
|
|
350
363
|
struct point* KM = alloc_points(size);
|
|
351
364
|
|
|
@@ -353,7 +366,7 @@ int kaplan_meier_3p_extrapolation(double* time, int* censored, int size, struct
|
|
|
353
366
|
if(cens_ucens_number->size > 6)
|
|
354
367
|
{
|
|
355
368
|
struct CENS_UC_NUM* updated_cens_ucens_number;
|
|
356
|
-
proc_state = KM_3p_extrapolation(&cens_ucens_number, &updated_cens_ucens_number, size);
|
|
369
|
+
proc_state = KM_3p_extrapolation(&cens_ucens_number, &updated_cens_ucens_number, size, max_time);
|
|
357
370
|
calculate_kaplan_meier(size, updated_cens_ucens_number, &KM);
|
|
358
371
|
KM_curve->point_array = KM;
|
|
359
372
|
KM_curve->size = updated_cens_ucens_number->size;
|
data/ext/sstat/sstat.o
CHANGED
|
Binary file
|
data/ext/sstat/sstat.so
CHANGED
|
Binary file
|
data/lib/sstat.so
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sstat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Haipeng Li
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2016-11-
|
|
13
|
+
date: 2016-11-22 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description:
|
|
16
16
|
email: haipeng3@ualberta.ca
|