This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
library('Seurat')
Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 methods overwritten by 'htmltools':
method from
print.html tools:rstudio
print.shiny.tag tools:rstudio
print.shiny.tag.list tools:rstudio
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
library('rpollock')
devtools::load_all('/Users/erikstorrs/Documents/ding/rpollock')
reticulate::use_python("/Users/erikstorrs/miniconda3/envs/pollock/bin/python")
pbmc = readRDS(('../tests/data/247669_processed.rds'))
pbmc
An object of class Seurat
48734 features across 2393 samples within 2 assays
Active assay: SCT (15196 features, 3000 variable features)
1 other assay present: RNA
2 dimensional reductions calculated: pca, umap
pbmc@meta.data$seurat_clusters
create_module(pbmc@assays$RNA@counts, pbmc@meta.data$seurat_clusters, '../tests/data/test_module', alpha=.0001, latent_dim=25, epochs=25, n_per_cell_type=100)
2020-06-09 11:52:33,312 normalizing counts for model training
2020-06-09 11:52:33,883 scaling data
2020-06-09 11:52:36,289 creating tf datasets
2020-06-09 11:52:37.168160: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-06-09 11:52:37.332521: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fe7d3a32dc0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-06-09 11:52:37.332540: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
WARNING:tensorflow:5 out of the last 13 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:48,504 5 out of the last 13 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
WARNING:tensorflow:6 out of the last 14 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:48,628 6 out of the last 14 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
WARNING:tensorflow:7 out of the last 15 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:48,728 7 out of the last 15 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
WARNING:tensorflow:8 out of the last 16 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:48,833 8 out of the last 16 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
WARNING:tensorflow:9 out of the last 17 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:48,925 9 out of the last 17 calls to <function compute_loss at 0x1ba1b1200> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings is likely due to passing python objects instead of tensors. Also, tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. Please refer to https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args and https://www.tensorflow.org/api_docs/python/tf/function for more details.
2020-06-09 11:52:54,244 epoch: 1, train loss: 210.177978515625, val loss: 209.50802612304688
2020-06-09 11:53:08,315 epoch: 2, train loss: 187.41152954101562, val loss: 185.93580627441406
2020-06-09 11:53:23,572 epoch: 3, train loss: 183.2262725830078, val loss: 180.92532348632812
2020-06-09 11:53:38,164 epoch: 4, train loss: 182.33688354492188, val loss: 179.6908416748047
2020-06-09 11:53:51,649 epoch: 5, train loss: 182.9647216796875, val loss: 179.4097442626953
2020-06-09 11:54:05,197 epoch: 6, train loss: 181.45069885253906, val loss: 178.96701049804688
2020-06-09 11:54:19,227 epoch: 7, train loss: 179.33078002929688, val loss: 177.29754638671875
2020-06-09 11:54:33,010 epoch: 8, train loss: 176.1165313720703, val loss: 175.27963256835938
2020-06-09 11:54:46,400 epoch: 9, train loss: 175.75302124023438, val loss: 174.60586547851562
2020-06-09 11:55:00,266 epoch: 10, train loss: 174.69839477539062, val loss: 174.04454040527344
2020-06-09 11:55:14,324 epoch: 11, train loss: 173.7620086669922, val loss: 173.37881469726562
2020-06-09 11:55:29,771 epoch: 12, train loss: 172.7646942138672, val loss: 172.80679321289062
2020-06-09 11:55:44,226 epoch: 13, train loss: 172.46119689941406, val loss: 172.3824462890625
2020-06-09 11:55:58,093 epoch: 14, train loss: 172.07421875, val loss: 172.1897735595703
2020-06-09 11:56:11,347 epoch: 15, train loss: 171.3411407470703, val loss: 171.9580841064453
2020-06-09 11:56:24,738 epoch: 16, train loss: 171.8856201171875, val loss: 171.81809997558594
2020-06-09 11:56:38,047 epoch: 17, train loss: 171.2698211669922, val loss: 171.7367706298828
2020-06-09 11:56:51,796 epoch: 18, train loss: 170.4576873779297, val loss: 171.60983276367188
2020-06-09 11:57:05,096 epoch: 19, train loss: 169.5643768310547, val loss: 171.5054931640625
2020-06-09 11:57:18,332 epoch: 20, train loss: 168.4552001953125, val loss: 171.37985229492188
2020-06-09 11:57:31,758 epoch: 21, train loss: 168.63267517089844, val loss: 171.24232482910156
2020-06-09 11:57:45,006 epoch: 22, train loss: 167.80079650878906, val loss: 171.15524291992188
2020-06-09 11:57:58,283 epoch: 23, train loss: 167.89613342285156, val loss: 171.0812530517578
2020-06-09 11:58:11,575 epoch: 24, train loss: 168.2134552001953, val loss: 170.9601593017578
2020-06-09 11:58:24,321 epoch: 25, train loss: 167.17689514160156, val loss: 170.8822479248047
# preds = predict_cell_types(pbmc@assays$RNA@counts, '../tests/data/HTAN_breast_v9/')
preds = predict_cell_types(pbmc@assays$RNA@counts, '../tests/data/test_module/')
2020-06-09 12:02:52,834 normalizing counts for prediction
2020-06-09 12:02:52,835 filtering for genes in training set
2020-06-09 12:02:52,847 0 genes in training set are missing from prediction set
/Users/erikstorrs/miniconda3/envs/pollock/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py:339: UserWarning: Revieved a view of an AnnData. Making a copy.
view_to_actual(adata)
2020-06-09 12:02:56,082 scaling data
preds
pbmc@assays$RNA
pbmc@assays$SCT
df = as.data.frame(pbmc@assays$RNA@counts)
df
ls = pbmc@meta.data$seurat_clusters
class(ls)
as.array(ls)
pollock = reticulate::import('pollock')
pollock
pollock$wrappers
preds = pollock$wrappers$rwrappers$predict_from_dataframe(df,
'../tests/data/HTAN_breast_v9/')
# pollock$wrappers$rwrappers$predict_from_dataframe
preds