|
1 | 1 | context("[NetworkDataCompanion] Testing getTissueType function ... ") |
2 | 2 |
|
3 | | -test_that("Testing getTissueType",{ |
| 3 | +numcodes <- c( |
| 4 | + "01", |
| 5 | + "02", |
| 6 | + "03", |
| 7 | + "04", |
| 8 | + "05", |
| 9 | + "06", |
| 10 | + "07", |
| 11 | + "08", |
| 12 | + "09", |
| 13 | + "10", |
| 14 | + "11", |
| 15 | + "12", |
| 16 | + "13", |
| 17 | + "14", |
| 18 | + "15", |
| 19 | + "16", |
| 20 | + "20", |
| 21 | + "40", |
| 22 | + "50", |
| 23 | + "60", |
| 24 | + "61", |
| 25 | + "99" |
| 26 | +) |
| 27 | + |
| 28 | +descriptions <- c( |
| 29 | + "Primary Solid Tumor", |
| 30 | + "Recurrent Solid Tumor", |
| 31 | + "Primary Blood Derived Cancer - Peripheral Blood", |
| 32 | + "Recurrent Blood Derived Cancer - Bone Marrow", |
| 33 | + "Additional - New Primary", |
| 34 | + "Metastatic", |
| 35 | + "Additional Metastatic", |
| 36 | + "Human Tumor Original Cells", |
| 37 | + "Primary Blood Derived Cancer - Bone Marrow", |
| 38 | + "Blood Derived Normal", |
| 39 | + "Solid Tissue Normal", |
| 40 | + "Buccal Cell Normal", |
| 41 | + "EBV Immortalized Normal", |
| 42 | + "Bone Marrow Normal", |
| 43 | + "sample type 15", |
| 44 | + "sample type 16", |
| 45 | + "Control Analyte", |
| 46 | + "Recurrent Blood Derived Cancer - Peripheral Blood", |
| 47 | + "Cell Lines", |
| 48 | + "Primary Xenograft Tissue", |
| 49 | + "Cell Line Derived Xenograft Tissue", |
| 50 | + "sample type 99" |
| 51 | +) |
| 52 | +my_friend = NetworkDataCompanion::CreateNetworkDataCompanionObject() |
| 53 | + |
| 54 | +test_that("Testing getTissueType for a single TCGA barcode",{ |
4 | 55 |
|
5 | | - my_friend = NetworkDataCompanion::CreateNetworkDataCompanionObject() |
6 | | - numcodes <- c( |
7 | | - "01", |
8 | | - "02", |
9 | | - "03", |
10 | | - "04", |
11 | | - "05", |
12 | | - "06", |
13 | | - "07", |
14 | | - "08", |
15 | | - "09", |
16 | | - "10", |
17 | | - "11", |
18 | | - "12", |
19 | | - "13", |
20 | | - "14", |
21 | | - "15", |
22 | | - "16", |
23 | | - "20", |
24 | | - "40", |
25 | | - "50", |
26 | | - "60", |
27 | | - "61", |
28 | | - "99" |
29 | | - ) |
30 | | - descriptions <- c( |
31 | | - "Primary Solid Tumor", |
32 | | - "Recurrent Solid Tumor", |
33 | | - "Primary Blood Derived Cancer - Peripheral Blood", |
34 | | - "Recurrent Blood Derived Cancer - Bone Marrow", |
35 | | - "Additional - New Primary", |
36 | | - "Metastatic", |
37 | | - "Additional Metastatic", |
38 | | - "Human Tumor Original Cells", |
39 | | - "Primary Blood Derived Cancer - Bone Marrow", |
40 | | - "Blood Derived Normal", |
41 | | - "Solid Tissue Normal", |
42 | | - "Buccal Cell Normal", |
43 | | - "EBV Immortalized Normal", |
44 | | - "Bone Marrow Normal", |
45 | | - "sample type 15", |
46 | | - "sample type 16", |
47 | | - "Control Analyte", |
48 | | - "Recurrent Blood Derived Cancer - Peripheral Blood", |
49 | | - "Cell Lines", |
50 | | - "Primary Xenograft Tissue", |
51 | | - "Cell Line Derived Xenograft Tissue", |
52 | | - "sample type 99" |
53 | | - ) |
54 | 56 | barcode = "TCGA-A1-1234-" |
55 | 57 | for(numcode in numcodes){ |
56 | 58 | expect_equal(as.character(my_friend$getTissueType(paste0(barcode, numcode))['description']), descriptions[numcodes == numcode]) |
57 | 59 | } |
58 | | - expect_true(is.na(as.character(my_friend$getTissueType(paste0(barcode, "53"))['description']))) |
| 60 | + expect_true(is.null(my_friend$getTissueType(paste0(barcode, "53")))) |
| 61 | +}) |
| 62 | + |
| 63 | +test_that("Testing getTissueType vectorizes properly",{ |
| 64 | + |
| 65 | + barcode1 = "TCGA-A1-1234-01A" |
| 66 | + barcode2 = "TCGA-A1-1234-10A" |
| 67 | + barcode3 = "TCGA-A1-1234-10B" |
| 68 | + barcode4 = "TCGA-A1-1234-02A" |
| 69 | + barcodes = c(barcode1, |
| 70 | + barcode2, |
| 71 | + barcode3, |
| 72 | + barcode4) |
| 73 | + |
| 74 | + expect_equal(my_friend$getTissueType(c(barcode1, |
| 75 | + barcode2, |
| 76 | + barcode3, |
| 77 | + barcode4))$description, |
| 78 | + c(descriptions[1], |
| 79 | + descriptions[10], |
| 80 | + descriptions[10], |
| 81 | + descriptions[2])) |
| 82 | +}) |
| 83 | + |
| 84 | +test_that("Testing getTissueType is not bamboozled by extra suffix items",{ |
| 85 | + |
| 86 | + barcode = "TCGA-A1-1234-01A-1989" |
| 87 | + expect_equal(my_friend$getTissueType(barcode)$description,descriptions[1]) |
| 88 | + |
59 | 89 | }) |
0 commit comments